Error in reading from file (Java) -
i posted similar question here: read file containing integers - java couldn't decent reply.
now have written new code reads file , outputs result.
i filenotfoundexception whenever try read file. code below:
import java.io.*; public class second { /** * @param args * @throws ioexception */ public static void main(string[] args) throws ioexception { file f = new file("c:\\users\\haroon\\workspace\\ppp\\temperature.txt"); filereader file = new filereader(f); bufferedreader buf = new bufferedreader(file); string s = null; while((s = buf.readline()) != null){ system.out.println(s); } }
}
this strange because file in project's folder. appreciated.
that should work. go location of file, copy path, paste in code, , escape slashes. missing something.
also check name/extension of file correct, have "temperature.txt.txt".
Comments
Post a Comment