I am new in java. I want to read a simple text file
I used this code:
import java.io.File;
import java.io.IOExcep tion;
import java.io.RandomA ccessFile;
import java.util.Date;
public class ForMe {
public static void main(String[] args) {
System.out.prin tln( "Testing File name-getting methods." );
System.out
.println(
"There must exist a TEST file called e:\\text.txt" );
// set up handle to file name.
File f = new File( "E:\\text.t xt" );
// does the file exist
if ( f.exists() )
{
System.out.prin tln( "file exists" );
}
else
System.out.prin tln("not exist");
}
I create a file named text.txt in E:
but it said not exist
I do not know why?!
I used this code:
import java.io.File;
import java.io.IOExcep tion;
import java.io.RandomA ccessFile;
import java.util.Date;
public class ForMe {
public static void main(String[] args) {
System.out.prin tln( "Testing File name-getting methods." );
System.out
.println(
"There must exist a TEST file called e:\\text.txt" );
// set up handle to file name.
File f = new File( "E:\\text.t xt" );
// does the file exist
if ( f.exists() )
{
System.out.prin tln( "file exists" );
}
else
System.out.prin tln("not exist");
}
I create a file named text.txt in E:
but it said not exist
I do not know why?!
Comment