wood burning stoves*
The moose likes Struts and the fly likes Converting Formfile to io file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Converting Formfile to io file" Watch "Converting Formfile to io file" New topic
Author

Converting Formfile to io file

Anil Kolisetty
Greenhorn

Joined: Feb 18, 2011
Posts: 9
I need to accept an excel file from a browser and need to pass that file to a method which accepts io file.
but the file which i receives from a browser is a fromfile.


can any provide solution for this.

Thanks in advance..........
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
have you tried org.apache.commons.fileupload?

Anil Kolisetty
Greenhorn

Joined: Feb 18, 2011
Posts: 9
i am using actionform as well as action class can you elobrate that FileUpload i.e how to read the uploaded file into action class using action form
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
It would be much easier to help if you posted some code so we could see what you have attempted and get and Idea of what you trying to accomplish.

cheers.
Anil Kolisetty
Greenhorn

Joined: Feb 18, 2011
Posts: 9
Receiving file from jsp using action form

ImportExcelForm myForm = (ImportExcelForm)form;
FormFile myFile = myForm.getTheFile();

i am accepting an excel file, i need to read this excel and need to distribute the data into different database tables.

i am rewriting this excel file in to local disk(server) as POI api accepts only io file.

InputStream inpstr= myFile.getInputStream();
FileOutputStream fos=new FileOutputStream("./BO.xls",false);
BufferedInputStream reader=new BufferedInputStream(inpstr,4096);
BufferedOutputStream writer=new BufferedOutputStream(fos,4096);
byte[] buf=new byte[4096];
int byteRead;
while ((byteRead=reader.read(buf,0,4096))>=0) {
writer.write(buf,0,byteRead);
}
reader.close();
writer.flush();
writer.close();

inputStream = new FileInputStream(xlsPath);
fileSystem = new POIFSFileSystem(inputStream);
HSSFWorkbook workBook = new HSSFWorkbook(fileSystem);
HSSFSheet sheet = workBook.getSheetAt(0);

but i want to pass the file from the browser directly to POI api and user should be able to upload multiple files at a time
Anil Kolisetty
Greenhorn

Joined: Feb 18, 2011
Posts: 9
can any one reply to the above problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting Formfile to io file
 
Similar Threads
DOM object not serializable !
I/O Classes
Standalone app worked... as Applet does not.
cancel tasks after a certain time
HttpServletResponse.getOutputStream() - streaming or not streaming?