File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
getResourceAsStream i get null.
Joined: May 17, 2002
Dec 08, 2010 06:42:39
I have a resource that i want to read in my main program, but i get null.
I have tryed to put the
"xl 2007" in the same directory as my
main program, but still i get null.
Any god ideas out there ?
InputStream input = POIExample.class.getClassLoader().getResourceAsStream("matrice.xlsx"); InputStream input = POIExample.class.getResourceAsStream("/home/efidev/Skrivebord/matrice.xlsx");
I running on a ubunto mashine.
Joined: Oct 27, 2005
Dec 08, 2010 07:05:55
With the first line you should put the .xlsx file in the same folder as the PIOExample.class file. If that's inside a JAR file then the .xlsx file should go in that JAR file as well.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
Joined: Sep 16, 2008
Dec 08, 2010 07:14:22
I think getResourceAsStream() method should be used when reading from .jar files. Try using plain
and stream objects.
SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
It is sorta covered in the
JavaRanch Style Guide
subject: getResourceAsStream i get null.
Inpust stream path issue
How to locate & write to files inside a Jar
Need to Read XMl File From Java Code
class.getResourcesAsStream couldn't find a specific type of file resource
getResourceAsStream(path) Path issue during validation
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015