• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scanner: file note being read  RSS feed

 
Ted Schrey
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this must be basic, but I can't figure it out... I am thinking that I don't really know where src files are and that might be the problem? In a nutshell, within my package, I have a Main Class, a Class to read text files and a text file. My main calls the file with location being src\filename.txt. With that, my printA and print B should show the text in the file, but all it shows is the filename. ...or is it something else?

Main:


Reader Class:


file named "testinput1.txt" just has two lines:

test
testagain
 
Carey Brown
Bartender
Posts: 3011
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try

What you have is the scanning of a String, in this case, the name of your file.
 
Ted Schrey
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got it. for my code to work, it would have to have had parameter File file, not String file, right? It only gave the name (String), and I had to use that name to create a file. Thanks!
 
Carey Brown
Bartender
Posts: 3011
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to be of help.
This is one of those cases where I would recommend a slightly more verbose variable name, and call it "fileName", instead of just "file".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!