• 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

IO - POI - HSSF

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I'm trying to use Apache POI to parse a XLS file with java.
When the file is in local I can do:
1 File file = new File("c:\\afile.xls");
2 InputStream is = file.toURL().openStream();
3 POIFSFileSystem fs = new POIFSFileSystem(is);
4 HSSFWorkbook wb = new HSSFWorkbook(fs);
without any problems.
It is working very well.
But when the file is on the web, I ave an instance of an HttpURLConnection to access it.
When I try the folloing:
1 InputStream is = httpURLCon.getUrl().openStream();
2 POIFSFileSystem fs = new POIFSFileSystem(is);
3 HSSFWorkbook wb = new HSSFWorkbook(fs);
I get a FileNotFoundException in line 3.
Does anyone knows a way to avoid this problem?
Thanks
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe your URL isn't correct...but we can't tell b/c we can't see that...
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think we should better verify whether the file we are going to use really exist or the path that we specify is correct by using yourFileObj.exists(). And then do things in the if statement... For instance,
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic