Q:

Why is FileWriter not creating a new file ?  FileNotFoundException

So I have a code snippet as follows.  Im trying to find out why it throws a FileNotFoundException.  
File file= new File (WORKSPACE_PATH+fname);
FileWriter fw;
if (file.exists())
{
     fw = new FileWriter(file,true);//if file exists append to file.  Works fine. 
}
else
{
     fw = new FileWriter(file);// If file does not exist.  Create it.  This throws a FileNotFoundException.  Why?  
}

A:

Using concatenation when creating the File won't add the necessary path separator. 
File file = new File(WORKSPACE_PATH, fname);

A:

You need to add a separator (Windows : \ and Unix : /, you can use File.separator to get the system's separator) if WORKSPACE_PATH does not have one at its end, and manually creating the file with its parent directories might help. 
Try this if WORKSPACE_PATH does not have a separator at its end :
File file = new File(WORKSPACE_PATH + File.separator + fname);

And add this before fw = new FileWriter(file);
file.mkdirs(); // If the directory containing the file and/or its parent(s) does not exist
file.createNewFile();

