function run() { $name = java_values(java_context()->getAttribute("name", 100)); // engine scope $out = new Java("java.io.FileOutputStream", "{$name}.out", true); $Thread = java("java.lang.Thread"); $nr = java_values(java_context()->getAttribute("nr", 100)); echo "started thread: {$nr}\n"; for ($i = 0; $i < 10; $i++) { $out->write(ord("{$nr}")); $Thread->yield(); } $out->close(); }
public static function saveToStream() { // The path to the documents directory. $dataDir = "/usr/local/apache-tomcat-8.0.22/webapps/JavaBridge/Aspose_Words_Java_For_PHP/src/quickstart/loadandsavetostream/data/"; // Open the stream. Read only access is enough for Aspose.Words to load a document. $stream = new Java("java.io.FileInputStream", $dataDir . "Document.doc"); // Load the entire document into memory. $doc = new Java("com.aspose.words.Document", $stream); // You can close the stream now, it is no longer needed because the document is in memory. $stream->close(); // ... do something with the document // Convert the document to a different format and save to stream. $dstStream = new Java("java.io.ByteArrayOutputStream"); $SaveFormat = new Java("com.aspose.words.SaveFormat"); $doc->save($dstStream, $SaveFormat->RTF); $output = new Java("java.io.FileOutputStream", $dataDir . "Document Out.rtf"); $output->write($dstStream->toByteArray()); $output->close(); }
//获取本机IP require_once "http://" . $ip . ":8080/JavaBridge/java/Java.inc"; //此行必须 $fs = new Java("com.zhuozhengsoft.pageoffice.FileSaverPHP"); //此行必须 $fs->load(file_get_contents("php://input")); //此行必须 java_set_file_encoding("GBK"); //设置编码格式 //获取通过Url传递过来的值 $id = 0; $id = $_REQUEST["id"]; $filepath = dirname($_SERVER["SCRIPT_FILENAME"]); $fs->saveToFile($filepath . "/page/" . $id . "/" . $fs->getFileName()); //保存文件 echo $fs->close(); //此行必须 ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'SaveFile.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page">
function saveOnlineEditWord() { // $ip = GetHostByName($_SERVER['SERVER_NAME']);//获取本机IP $ip = C("DB_HOST_WORD"); //"192.168.0.238"; require_once "http://{$ip}:8088/JavaBridge/java/Java.inc"; //此行必须 $fs = new Java("com.zhuozhengsoft.pageoffice.FileSaverPHP"); //此行必须 echo $fs->close(); //此行必须 $fs->load(file_get_contents("php://input")); //此行必须 java_set_file_encoding("utf8"); //设置编码格式 $socuse = str_replace("\\", "/", base64_decode($_REQUEST['name'])); $file_path = str_replace("\\", "/", UPLOAD_PATH . $socuse); $fs->saveToFile($file_path); //保存文件 echo $fs->close(); //此行必须 }
} //解析存储 if (!($handle = fopen($jiexiFile, 'a'))) { $content .= "解析文件打不开!"; } else { // 将$somecontent写入到我们打开的文件中。 if (fwrite($handle, $doc->openDataRegion("PO_jiexi")->getFileBytes()) === FALSE) { $content .= "不能写入到解析!"; } else { $content .= "成功写入解析"; fclose($handle); } } //$doc->showPage(500, 400); $doc->setCustomSaveResult($questionDoc . "-" . $answerDoc . "-" . $jiexiDoc); echo $doc->close(); /*$ch = curl_init("http://".$ip."/uteach/Word/FileMakerSingle.php?id=".$id."&type=question"); curl_exec($ch); curl_close($ch); $ch = curl_init("http://".$ip."/uteach/Word/FileMakerSingle.php?id=".$id."&type=answer"); curl_exec($ch); curl_close($ch); $ch = curl_init("http://".$ip."/uteach/Word/FileMakerSingle.php?id=".$id."&type=jiexi"); curl_exec($ch); curl_close($ch);*/ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head>