java - Program that cannot acess input from a file -
i have program scans file , closes file.
import java.util.*; import java.io.*; public class filetester{ public static void main(string[] args) throws ioexception { file test = new file("mydatta.in.txt"); scanner sf = new scanner(test); sf.close(); } }
when run program error message this:
exception in thread "main" java.io.filenotfoundexception: mydatta.in.txt (no such file or directory) @ java.io.fileinputstream.open(native method) @ java.io.fileinputstream.<init>(fileinputstream.java:120) @ java.util.scanner.<init>(scanner.java:636) @ filetester.main(filetester.java:6)
i have mac runs on mac os. have reason believe has pathway file in documents. know in windows 1 use c:\folder name\file
scan don't know mac , cannot find anywhere
you should put file path:
~/documents/mydatta.in.txt
to tell java file in documents. ~
home folder.
Comments
Post a Comment