I want to read a file and its directory using scanner. The problem is the directory is not read through scanner because there is a white space in it. I tried to handle it with S.nextLine() but it doesn't skip execution and skip to the rest of the code. 
This is the code:
public class readFile {
   public static void main (String args[]){
    System.out.print("Enter test file directory: ");
    testFile = S.nextLine();
    //testFile = "C:\\Users\\firstname lastname\\Desktop\\test1.txt"; This works 
    File test = new File(testFile);
    try
    {
      Scanner readFile = new Scanner(test);
      while(readFile.hasNextLine())
     {
        int i = readFile.nextInt();
        System.out.println(i);
     }
     readFile.close();
     }catch(FileNotFoundException e){System.out.println("File doesn't exist");}
   }
}  
