S
stevesuts
I am trying to write to a file using an EJB. I need to put the file on
the server for an FTP process. Does anyone have some example code that
will do that? Here is what I have so far, but I am having trouble...
public int writeToFile(String aosData) {
int returnCde = 0;
try
{
String dirName = ("c:\\AOSFTP");
String aosFileName = ("aosFtpFile.txt");
File aosFileDir = new File(dirName);
FileWriter fileWriter = new FileWriter(aosFileName);
BufferedWriter buffWriter = new BufferedWriter(fileWriter);
if(!aosFileDir.exists())
{
aosFileDir.mkdir();
}
else if(!aosFileDir.isDirectory())
{
System.out.println("The Directory does not exist");
returnCde = 1;
}
File aosFile = new File(dirName, aosFileName);
aosFile.createNewFile();
buffWriter.write(aosData);
buffWriter.flush();
buffWriter.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return (returnCde);
}
Any help is greatly appreciated.
the server for an FTP process. Does anyone have some example code that
will do that? Here is what I have so far, but I am having trouble...
public int writeToFile(String aosData) {
int returnCde = 0;
try
{
String dirName = ("c:\\AOSFTP");
String aosFileName = ("aosFtpFile.txt");
File aosFileDir = new File(dirName);
FileWriter fileWriter = new FileWriter(aosFileName);
BufferedWriter buffWriter = new BufferedWriter(fileWriter);
if(!aosFileDir.exists())
{
aosFileDir.mkdir();
}
else if(!aosFileDir.isDirectory())
{
System.out.println("The Directory does not exist");
returnCde = 1;
}
File aosFile = new File(dirName, aosFileName);
aosFile.createNewFile();
buffWriter.write(aosData);
buffWriter.flush();
buffWriter.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return (returnCde);
}
Any help is greatly appreciated.