Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing to a file from an EJB  RSS feed

 
Steve Sutton
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a ejb cache that I am retrieving data from and writing that data to a file for ftp processing. I am using an ejb to do that that will be called via a timed function. I am having a problem getting anything to write to the file that is being created. The directory and file get created and I recieve no error messages from my write, but nothing shows up in my file. Here is the code that I am executing:

try
{
String dirName = ("c:\\AOSFTP");
String aosFileName = ("aosFtpFile.txt");
File aosFileDir = new File(dirName);
File aosFile = new File(dirName, aosFileName);
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");
return(1);
}
if(!aosFile.exists())
{
aosFile.createNewFile();
}

buffWriter.write(aosData);


buffWriter.flush();
//buffWriter.close();


}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}


Everything except the data is showing up......Any help would be greatly appreciated.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are sure about the contents of aosData?
 
Steve Sutton
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am positive. I took out a system print statement that shwoed data in the string. So, I am thinking that I don't have something right in the write statement :~).....
 
Ken Loh
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, can't resist to view your codes in its true indentations.

Originally posted by Steve Sutton:
I have a ejb cache that I am retrieving data from and writing that data to a file for ftp processing. I am using an ejb to do that that will be called via a timed function. I am having a problem getting anything to write to the file that is being created. The directory and file get created and I recieve no error messages from my write, but nothing shows up in my file. Here is the code that I am executing:


Everything except the data is showing up......Any help would be greatly appreciated.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!