java - Failing to print out contents of a file -
i'm trying print out contents of file. when run program, doesn't , i'm having trouble figuring out why.
public static void main(string[] args) { string filename = "goog.csv"; file file = new file(filename); try { scanner inputstream = new scanner(file); while(inputstream.hasnext()){ string data = inputstream.next(); system.out.println(data + "***"); } inputstream.close(); } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } }
need give full path of goog.csv file. put goog.csv file in workspace .metadata directory give full path of file giving output because tried code on system. change goog.csv file mine firmpicture.csv file.
public static void main(string[] args) { string filename = "filepath"; file file = new file(filename); try { scanner inputstream = new scanner(file); while(inputstream.hasnext()){ string data = inputstream.next(); system.out.println(data + "***"); } inputstream.close(); } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } }
Comments
Post a Comment