// 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 );
}