// Variable Declaration
Java. lang. String strFileName; // file name
Java. io. File objFile; // File object
Java. io. FileReader objFileReader; // read object
Char [] chrBuffer = new char [10]; // Buffer
Int intLength; // number of characters actually read (a Chinese character is a character)
// Set the file name to be read
StrFileName = "d :\\ test.txt ";
// Create a file object
ObjFile = new java. io. File (strFileName );
// Determine whether a file exists
If (objFile. exists () {// The object exists.
// Create a read object
ObjFileReader = new java. io. FileReader (objFile );
// Read the file content
While (intLength = objFileReader. read (chrBuffer ))! =-1 ){
// Output
Out. write (chrBuffer, 0, intLength );
}
// Close the read object
ObjFileReader. close ();
}
Else {// the file does not exist
Out. println ("the following file does not exist:" + strFileName );
}