aspose file tools*
The moose likes I/O and Streams and the fly likes FileNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "FileNotFoundException" Watch "FileNotFoundException" New topic
Author

FileNotFoundException

Jaykiran Teraiya
Greenhorn

Joined: Jun 21, 2010
Posts: 12
Hello Everyone..

I have following code inside my method.


When I execute my webapplication, I am getting below error message.


I made sure that I've write access to the tomcat directory.

Any help would be appreciated.

Thanks
Jay
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Well champ, it appears to be a permission problem. Please try to write your file to another directory (such as C:\Jaykiran), just to make sure it isn't a permission problem.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Jaykiran Teraiya
Greenhorn

Joined: Jun 21, 2010
Posts: 12
Hi Roberto,

I guess that was the problem. Thanks for the solution. I've given my home directory path to resolve this, but the problem is what path should I give when I deploy the application to production server? We are using apache tomcat 6 in production.

Thanks
Jay

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18986
    
    8

Make a directory for the use of this application and save the files there. It's up to you to choose a suitable place on the server.

(By the way, do you really need to write files to disk from Tomcat? Why?)
Jaykiran Teraiya
Greenhorn

Joined: Jun 21, 2010
Posts: 12
I am trying to generate a very large excel file from the database result set. I am using apache poi XSSF api. It has very high memory foot print so I was running into java heap space exception. I found one solution BigGrid Demo. I am doing proof of concept with my large data set, ultimately I have to write the entire thing to ServletOutputStream, so that user can download it directly.

But it seems that as file size is growing, data is getting corrupted and even this solution does not seem to work

do you have any idea about this kind of issue and it's probable solution.

Thanks
Jay
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18986
    
    8

Half of the solution is to write the document directly to the servlet's output stream, instead of writing it to a file and then copying that file to the output stream. (By the way, the File class has methods which make it unnecessary for you to choose a directory where temp files will be stored.)

However, as you are finding, the other half of the problem is to make sure your document isn't so large that it causes Tomcat to run out of memory. This has nothing to do with I/O or streams at all. You can give Tomcat more memory, up to a point, but once your documents get too large for that you are out of luck. You would have to produce multiple smaller documents, or something like that.
Jaykiran Teraiya
Greenhorn

Joined: Jun 21, 2010
Posts: 12
Hi Paul,

Thanks for the reply. I'll try to remove the intermediate file steps and write directly to the servletoutputstream. Let's see how does that work.

Thanks
Jay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileNotFoundException