Assignment 123, Simple File Input
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: Simple File Input
///File Name: Data2.java
///Date Finshed: 6/06/16
import java.io.File;
import java.util.Scanner;
public class Data2 {
public static void main(String[] args) throws Exception {
String name;
System.out.print("Getting name from file.....");
Scanner fileIn = new Scanner(new File("name.txt"));
name = fileIn.nextLine();
fileIn.close();
System.out.println("Your name is: " + name);
}
}
Picture of the output