Why isn't the file created or why can't the path be found?
<p>So I am creating the following code to create a new file. Does anyone know why it's throwing the exception? </p>

<p>Essentially, I thought it was going to check if a file exists after using the constructor and it doesn't, I thought it would create it but neither happened.</p>

<pre><code>Java Code:


import java.util.Scanner;
import java.lang.Integer;
import java.io.*;
import java.lang.*;
import java.io.File;

class CreateNumberFile{
    public static void main(String args[]){
        //Ask user for filename and highest number
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the filename");
        String fileName = in.next();
        System.out.println("Enter the highest number for this file");
        int maxNumber = in.nextInt();

        System.out.print("A file titled " + fileName+ " will be created containing a");
        System.out.println(" string of numbers with numbers ranging from 0 to: " + maxNumber);

        // Create a File object 
        File myFile = new File("home/Users/Joe/Dropbox/Programming/Java/Projects/g2.txt");
        // Tests whether the file or directory denoted by this abstract 
        //pathname exists.
        if (myFile.exists()) {
            System.out.println(myFile.getAbsolutePath() +
                    " File already exists");

        } else {
          try{
            //creates a new, empty file named by this pathname
            myFile.createNewFile();
            System.out.println(myFile.getAbsolutePath() + 
                    " File Created Successfully");
          } catch(IOException e){
            System.err.println ("Caught IOException "+e.getMessage());
          }
        }

    }//main
}//class
</code></pre>

<p>When I run it, I get the following error:</p>

<p>Output:</p>

<pre><code>Caught IOException The system cannot find the path specified
</code></pre>

<p>I thought the code would check if the file exists and if it doesn't, I would use the constructor to create the file? any ideas?</p>
