| Author |
Converting Formfile to io file
|
Anil Kolisetty
Greenhorn
Joined: Feb 18, 2011
Posts: 8
|
|
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: 8
|
|
|
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: 8
|
|
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: 8
|
|
|
can any one reply to the above problem
|
 |
 |
|
|
subject: Converting Formfile to io file
|
|
|