Q:

Getting exception while trying to get FileOutputStream

We are getting the following exception while trying to get FileOutputStream for a filename:
java.lang.Exception: /var/tmp (Is a directory)
Please suggest what can be the cause of the error.
Code snippet where exception occurs:
public static FileOutputStream getFileInternal()
{
String pFilename = "/usr/tmp/";
File f = new File(pFilename);
pFilename = f.getCanonicalPath();
FileOutputStream fo = null;
fo = new FileOutputStream(pFilename, true);
return fo;
}

A:

"/usr/tmp/" is a directory.
FileOutputStream only writes into regular files, not directories.
You can try something like:
String pFilename = "/usr/tmp/output.txt";
// ...

