• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Converting Formfile to io file

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..........
 
Ranch Hand
Posts: 111
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you tried org.apache.commons.fileupload?

 
Anil Kolisetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can any one reply to the above problem
 
I knew I would regret that burrito. But this tiny ad has never caused regrets:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic