Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting Formfile to io file

 
Anil Kolisetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you tried org.apache.commons.fileupload?

 
Anil Kolisetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one reply to the above problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic