Assignemnt #123: SimpleFileInput
Code
/// Name: Kelsey Lieberman
/// Period 5
/// Program Name: SimpleFileInput
/// File Name: SimpleFileInput.java
/// Date Finished: 2/19/2016
import java.util.Scanner;
import java.io.File;
public class SimpleFileInput
{
public static void main(String[] args) throws Exception
{
Scanner fileIn = new Scanner(new File("name.txt"));
String firstname = fileIn.next();
String lastname = fileIn.next();
fileIn.close();
System.out.println("\nUsing my psychic powers (aided by reading data from the file), I have ");
System.out.print("determined your name is: " + firstname + " " + lastname + ".\n\n");
}
}
Picture of the output