You are viewing our Forum Archives. To view or take place in current topics click here.
Need help with an input file (JAVA)
Posted:

Need help with an input file (JAVA)Posted:

Windyc1tyflyer
  • Wise One
Status: Offline
Joined: Mar 23, 201014Year Member
Posts: 531
Reputation Power: 20
Status: Offline
Joined: Mar 23, 201014Year Member
Posts: 531
Reputation Power: 20
So i'm trying to input a file with a Scanner and when my program gets to the part where its supposed to open the file, it shows the package (or location) of the file instead of opening it. Anyone know why this may be happening?
#2. Posted:
Tums
  • TTG Senior
Status: Offline
Joined: Nov 25, 201013Year Member
Posts: 1,656
Reputation Power: 69
Status: Offline
Joined: Nov 25, 201013Year Member
Posts: 1,656
Reputation Power: 69
Can you post some code? Reading text from a file is relatively simple, here's an example.


Scanner input = new Scanner(new File("filepath/filename"));
// To read in a line..
input.nextLine();


Obviously there's different and more elegant ways to do this kind of stuff too, but this is the most simple representation of reading data from a file.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.