title: How to open a file in a java program?
body: <p>my professor wants us to write a program that will open a file and read the lines and he gave this example;</p>
  
  <pre><code>import java.io.*;
  import java.util.Scanner;
  import java.io.IOException;
  
  public class LineNumbers {
  
  public static void main(String[] args) throws IOException
  
    {
         // Create a Scanner object for keyboard input.
        Scanner keyboard = new Scanner(System.in);
  
        // Get the filename.
        System.out.print("Enter the filename: ");
        String filename = keyboard.nextLine();
  
        // Open the file.
        File file = new File(filename);
        Scanner inputFile = new Scanner(file);
  
        // Read lines from the file until no more are left.
        while (inputFile.hasNext())
        {
           // Read the next name.
           String familyName = inputFile.nextLine();
  
           // Display the last name read.
           System.out.println(familyName);
  
              }
  
        // Close the file.
        inputFile.close();
        keyboard.close();
  }
  
  }
  </code></pre>
  
  <p>The problem is, once I run the program and it tells me to enter the filename, what exactly do I type? If I make a random text file named "test" on my desktop and input "test" into the program it won't open it up. Am I supposed to type some special character to open it up and have it read? Thank you. </p>