I have been trying to figure out why I can't see anything written to a file. I can create the directory, create the file, but when it comes to writing anything to it, I can't.
Here is the 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();
}
The canWrite function returns 'true', so I am assuming that there are no permission issues stopping me. Any help is greatly appreciated..
Here is the 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();
}
The canWrite function returns 'true', so I am assuming that there are no permission issues stopping me. Any help is greatly appreciated..