Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot get the info from disk file

 
vincent donald
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this code that i have writen here does'nt want to collect my data from the file.I am still a beginner in java.If someone can give me some help?






import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

public class importDataProcess {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException {


String name;
int testValues;

Scanner diskScanner =
new Scanner(new File("C:\\testdata.text"));

name = diskScanner.nextLine();
testValues = diskScanner.nextInt();
}


}
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

So, what happens? Does the code compile? Do you get a runtime error (if so, what?) Does it simply not do what you expect? Please let us know, and we'll be better able to help you.
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future please put your code in code tags. Your code will be much more readable, and people will be more inclined to help you. Sorry, i do not know the answer. It has been a while since i have done stuff with reading files and the like.

 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vincent donald wrote:this code that i have writen here does'nt want to collect my data from the file.

ItDoesntWorkIsUseless. What does it do instead? And what's the contents of the file? Please TellTheDetails.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic