could not find text file, java file I/O error -
not sure why won't read txt file saved in same directory. compiled fine when enter java blindfoldsaside
cmd ln, says cannot find or load main class blindfoldsaside. case correct far can see , in right file path, i'm not sure went wrong!
package blindfoldsaside; import java.io.bufferedreader; import java.io.fileinputstream; import java.io.filereader; import java.io.ioexception; import java.util.scanner; public class blindfoldsaside { public static void main (string[] args) { scanner scannerin = null; fileinputstream in = null; bufferedreader inputstream = null; int filechar; //character's int equivalent string fileline; try { // fileinputstream calls txt file in = new fileinputstream("blindfoldsaside.txt"); system.out.println("these lyrics tell story of woman, named kezia, is" + " \nbeing put death after being forced prostitution. song prison" + " \nguard's (who executioner) point of view. hope enjoy."); // reads file 1 char @ time while ((filechar = in.read()) != -1) { system.out.print((char) filechar); }// end while system.out.println(""); //separates file output system.out.println(""); system.out.println("this song written arif mirabdolbaghi (bassist) , performed " + " protest hero. song appears on band's first full length album, kezia, " + " released in native country (canada) on august 30th, 2005 , u.s. on " + " april 4th, 2006. 6th track on album."); } catch (ioexception io) { system.out.println("file io exception" + io.getmessage()); } { try { if (in != null) { in.close(); }// end if if (inputstream != null) { inputstream.close(); }// end if } catch (ioexception io) { system.out.println("there problem closing files" + io.getmessage()); }// end catch }// end }// end main }// end class
try moving txt file project root folder. should work no issues. lest me know if changed or if worked fine.
Comments
Post a Comment