コード例 #1
0
function dump_java_exception($ex)
{
    $trace = new java("java.io.ByteArrayOutputStream");
    echo "Java Exception in File '" . $ex->getFile() . "' Line:" . $ex->getLine() . " - Message: " . $ex->getCause()->toString();
    $cause = $ex->getCause();
    $cause->printStackTrace(new java("java.io.PrintStream", $trace));
    echo "<PRE>Java Stack Trace:\n" . $trace->toString() . "\n</PRE>";
}
コード例 #2
0
/** create a temporary directory for the lucene index files. Make sure
 * to create the tmpdir from Java so that the directory has
 * javabridge_tmp_t Security Enhanced Linux permission. Note that PHP
 * does not have access to tempfiles with java_bridge_tmp_t: PHP
 * inherits the rights from the HTTPD, usually httpd_tmp_t.
 */
function create_index_dir()
{
    global $tmp_file, $tmp_dir;
    $javaTmpdir = java("java.lang.System")->getProperty("java.io.tmpdir");
    $tmpdir = java_values($javaTmpdir);
    $tmp_file = tempnam($tmpdir, "idx");
    $tmp_dir = new java("java.io.File", "{$tmp_file}.d");
    $tmp_dir->mkdir();
    return java_values($tmp_dir->toString());
}
コード例 #3
0
include_once "java/Java.inc";
ini_set("max_execution_time", 0);
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
$binaryData = new java("BinaryData");
$data = java_values($binaryData->getData(700 * 1024));
for ($i = 0; $i < 10; $i++) {
    $data = java_values($binaryData->compare($data));
    $str1 = substr($data, 255, 256);
}
$str = '&;a&amp;&quote"&quot;&&&;;"';
$binaryData->b = '&;a&amp;&quote"&quot;&&&;;"';
$binaryData->compare('&;a&amp;&quote"&quot;&&&;;"');
if ($str != java_values($binaryData->toString())) {
    echo "ERROR\n";
    exit(1);
}
$data = java_values($binaryData->getData(1024));
if (strlen($data) != 1024) {
    echo "ERROR\n";
    exit(5);
}
$s1 = substr(java_values($binaryData->toString()), 0, 256);
$binaryData->b = $str1;
$s2 = substr(java_values($binaryData->toString()), 0, 256);
if ($s1 != $s2) {
    echo "ERROR\n";
    exit(2);
}
コード例 #4
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$file_encoding = "ASCII";
java_set_file_encoding($file_encoding);
$out = new java("java.io.ByteArrayOutputStream");
$stream = new java("java.io.PrintStream", $out);
$str = new java("java.lang.String", "Cześć! -- שלום -- Grüß Gott", "UTF-8");
$stream->print($str);
echo "Stream: " . $out->__toString() . "\n";
echo "Stream as {$file_encoding} string: " . java_values($out->toString()) . "\n";
echo "Stream as binary data: " . java_cast($out->toByteArray(), "S") . "\n";