exception - FileNotFoundException when reading from text document -


i'm trying read file from

public static void printlines(string doc){      scanner input = null;     input = new scanner(doc + ".txt"));       while(input.hasnext()){          string nextline = input.nextline();         system.out.println(nextline);      }      input.close;  } 

the code above method takes in string doc parameter, , prints out every line. in main, used try catch block catch filenotfoundexception. however, when try running program, hits filenotfoundexception time.

i'm using eclipse , text file , java file both in same "java project". there reason why method can't read text file? please help!

try print doc inside it. may including extension of file too.

for example, if doc /home/user/desktop/mysample.txt scanner try find /home/user/desktop/mysample.txt.txt not available, because concatenating extension .txt again.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -