req.onreadystatechange = processReqChange;
閭d箞鎴戜滑鎺ョ潃瑕佹湁涓涓猵rocessReqChange鐨勫嚱鏁幫細function processReqChange()
{
// only if req shows "complete"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200)
{
// ...processing statements go here...
processResponse();
} else {
alert("There was a problem retrieving
the XML data:\n" + req.statusText);
}
}
}
function processResponse()
{
response = req.responseXML.documentElement;
method = response.getElementsByTagName('method')[0].firstChild.data;
result = response.getElementsByTagName('result')[0].firstChild.data;
eval(method + '(\'\', result)');
}
娉細
1- Make sure u have Installed Apache 2 & PHP 5 and Java J2EE 1.5
2- download pecl-5.0.5-Win32.zip and php-java-bridge_2.0.8.zip, which will include
extra dll(s)
聽聽 - unpack pecl pkg to your extensions folder, in PHP5 its ext.
聽聽 - unpack java-Bridge to root php folder, in my case its simply C:\PHP
聽聽
Note:
1. the java-Bridge inculdes new versions of certain files like php_java.dll
聽聽 so, it would be wise to rename your old files that came with PECL pkg for example
聽聽 file_old, to rollback at anytime.
2. Don't run batch file under php-java-bridge after unpacking to php root folder, just add following lines in php.ini configure file (depends on installation fold of j2ee):
extension=php_java.dll
extension_dir = "C:\php\ext"
[java]
java.java_home=C:\Program Files\Java\jre1.5.0_06
java.java=C:\Program Files\Java\jre1.5.0_06\bin\javaw.exe
java.log_level=2
;java.log_file=ext/JavaBridge.log
try
{
InetAddress addr = InetAddress.getByName("yahoo.com");
byte[] ipAddr = addr.getAddress();
// Convert to dot representation
String ipAddrStr = "";
for (int i=0; i<ipAddr.length; i++) {
if (i > 0) {
ipAddrStr += ".";
}
ipAddrStr += ipAddr[i]&0xFF;
}
}
catch (UnknownHostException e) {
}
getHostName()
may not succeed, in which case it simply
returns the IP address.
try {
// Get hostname by textual representation of IP address
InetAddress addr = InetAddress.getByName("127.0.0.1");
// Get hostname by a byte array containing the IP address
byte[] ipAddr = new byte[]{127, 0, 0, 1};
addr = InetAddress.getByAddress(ipAddr);
// Get the host name
String hostname = addr.getHostName();
// Get canonical host name
String hostnameCanonical = addr.getCanonicalHostName();
} catch (UnknownHostException e) {
}
try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}
=================================================================== File: foo.c Status: Needs Merge Working revision: 1.1.1.1 'Some Date' Repository revision: 1.2 /class/'username'/cvsroot/project/foo.c,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none)The various status of a file are:
void foo() { printf("FOO\n"); <<<<<<< foo.c printf("TOO\n"); ======= printf("YOU\n"); >>>>>>> 1.2 }
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str = "";
while (str != null)
{
System.out.print("> some prompt ");
str = in.readLine();
dosomethingwith(str);
}
}
catch (IOException e)
{
}
try
{
BufferedReader in = new BufferedReader(new FileReader("filename"));
String str;
while ((str = in.readLine()) != null)
{
dosomethingwith(str);
}
in.close();
}
catch (IOException e)
{
}
// Returns the contents of the file in a byte array.
public static byte[] getBytesFromFile(File file) throws IOException
{
InputStream is = new FileInputStream(file);
// Get the size of the file
long length = file.length();
// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE)
{
// File is too large
}
// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0)
{
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length)
{
throw new IOException("Could not completely read file "+file.getName());
}
// Close the input stream and return bytes
is.close();
return bytes;
}
tryNote: If the file does not already exist, it is automatically created.
{
BufferedWriter out = new BufferedWriter(new FileWriter("filename"));
out.write("some string");
out.close();
}
catch (IOException e)
{
}
try
{
BufferedWriter out = new BufferedWriter(new FileWriter("filename", true));
out.write("appending String");
out.close();
}
catch (IOException e)
{
}
tryreference:
{
File f = new File("filename");
RandomAccessFile raf = new RandomAccessFile(f, "rw");
// Read a character
char ch = raf.readChar();
// Seek to end of file
raf.seek(f.length());
// Append to the end
raf.writeChars("aString");
raf.close();
}
catch (IOException e)
{
}