S
stevesuts
I posted earlier about writing to a file from an ejb and found that you
can't do that so I am now calling a function outside of my bean that I
pass a vector to. I am not even trying to write the vector contents, I
have hard coded a string to be written to the file. I can creat the
directory, create the file, but I can't write to it. Here is my code.
try
{
String dirName = ("c:\\AOSFTP");
String aosFileName = ("aosFtpFile.txt");
File aosFileDir = new File(dirName);
File aosFile = new File(dirName, aosFileName);
PrintWriter fout = new PrintWriter(new FileWriter(aosFileName));
if(!aosFileDir.exists())
{
aosFileDir.mkdir();
}
else if(!aosFileDir.isDirectory())
{
System.out.println("The Directory does not exist");
return(1);
}
if(!aosFile.exists())
{
aosFile.createNewFile();
}
System.out.println(" you can " +(aosFile.canWrite()?" ":"not " )+
"write " + fout);
fout.println("Hi there Steve. I made it into the file");
fout.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
I get a 'true' return from my canWrite function, so I am assuming that
there are no permission problems. Any help is greatly appreciated.
can't do that so I am now calling a function outside of my bean that I
pass a vector to. I am not even trying to write the vector contents, I
have hard coded a string to be written to the file. I can creat the
directory, create the file, but I can't write to it. Here is my code.
try
{
String dirName = ("c:\\AOSFTP");
String aosFileName = ("aosFtpFile.txt");
File aosFileDir = new File(dirName);
File aosFile = new File(dirName, aosFileName);
PrintWriter fout = new PrintWriter(new FileWriter(aosFileName));
if(!aosFileDir.exists())
{
aosFileDir.mkdir();
}
else if(!aosFileDir.isDirectory())
{
System.out.println("The Directory does not exist");
return(1);
}
if(!aosFile.exists())
{
aosFile.createNewFile();
}
System.out.println(" you can " +(aosFile.canWrite()?" ":"not " )+
"write " + fout);
fout.println("Hi there Steve. I made it into the file");
fout.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
I get a 'true' return from my canWrite function, so I am assuming that
there are no permission problems. Any help is greatly appreciated.