Prog 122: Data From a File
//Name: Ilana Levy
//Period: 5
//Program Name: Data from another File
//File Name: getData.java
//Date Finished: 2/11/16
import java.io.File;
import java.util.Scanner;
public class getData {
public static void main(String[] args) throws Exception {
String name;
int a, b, c, sum;
System.out.print("Getting name and three numbers from file.....");
Scanner fileIn = new Scanner(new File("Z:\\compsci\\intro\\fileIO\\122\\name-and-number.txt"));
name = fileIn.nextLine();
a = fileIn.nextInt();
b = fileIn.nextInt();
c = fileIn.nextInt();
fileIn.close();
System.out.println("done.");
System.out.println("Your name is: " + name);
sum = a + b + c;
System.out.println(a + " + " + b + " + " + c + " = " + sum);
}
}
\\This might cause a problem as the scanner goes chronologically. It is difficult to isolate a single number.