_Esam
asked on
getResourceAsStream Error?
Hi,
I am trying to parse an XML file using a custom XML parser.
But I am just not even being able to read it ???
I have CECEVFeedConfigParameters class that uses the parser, and in it I tried:
InputStream lConfigFileInputStream =
((Class)mClass)
.getResourceAsStream
(CEC_EV_FEED_CFG_FILE);
if (lConfigFileInputStream == null)
{
throw new TransferSystemException
("CEC EV Feed config file "+
CEC_EV_FEED_CFG_FILE +
" missing");
}
I have an Interface where I declared:
public static final String
CEC_EV_FEED_CFG_FILE = "C:\\Projects\\CECEVFeedCo nfigParame ters.xml";
In my main class I tried as:
File lCECEVFeedFilePath = null;
try{
lCECEVFeedFilePath =
new File(CECEVFeedConfigParame ters.getIn stance().g etDataFile Path());
}
catch(Exception e){
e.printStackTrace();
System.out.println("Could not parse");
}
And I get the error:
null
.........................T ransferSys temExcepti on printStackTrace:
.........................T ransferSys temExcepti on: CEC EV Feed config file C:\Projects\CECEVFeedConfi gParameter s.xml missing
at ............util.CECEVFeed ConfigPara meters.get Instance(C ECEVFeedCo nfigParame ters.java: 123)
at .............EmailMain.rea d(EmailMai n.java:35)
at ..............EmailMain.ma in(EmailMa in.java:10 1)
.......................... .........T ransferSys temExcepti on: 0
Imbedded Exception = java.lang.Exception
Imbedded Exception
message =
Fri Jun 02 01:40:32 CDT 2006
5
2
5
Here
Could not parse
I NEED TO KNOW WHAT I NEED TO DO SO THAT I CAN READ THE XML FILE ..... (NOT TO THINK ABOUT PARSING NOW :)
I AM JUST RUNNING THE APP WITH ECLIPSE ..
DO I NEED TO SET UP THE CLASSPATH ??? FOR THE RESOURCE???
NEED A SOLUTION ......(FULL POINTS DUE TO ........)
LET ME KNOW..
Thax.
_Esam
I am trying to parse an XML file using a custom XML parser.
But I am just not even being able to read it ???
I have CECEVFeedConfigParameters class that uses the parser, and in it I tried:
InputStream lConfigFileInputStream =
((Class)mClass)
.getResourceAsStream
(CEC_EV_FEED_CFG_FILE);
if (lConfigFileInputStream == null)
{
throw new TransferSystemException
("CEC EV Feed config file "+
CEC_EV_FEED_CFG_FILE +
" missing");
}
I have an Interface where I declared:
public static final String
CEC_EV_FEED_CFG_FILE = "C:\\Projects\\CECEVFeedCo
In my main class I tried as:
File lCECEVFeedFilePath = null;
try{
lCECEVFeedFilePath =
new File(CECEVFeedConfigParame
}
catch(Exception e){
e.printStackTrace();
System.out.println("Could not parse");
}
And I get the error:
null
.........................T
.........................T
at ............util.CECEVFeed
at .............EmailMain.rea
at ..............EmailMain.ma
..........................
Imbedded Exception = java.lang.Exception
Imbedded Exception
message =
Fri Jun 02 01:40:32 CDT 2006
5
2
5
Here
Could not parse
I NEED TO KNOW WHAT I NEED TO DO SO THAT I CAN READ THE XML FILE ..... (NOT TO THINK ABOUT PARSING NOW :)
I AM JUST RUNNING THE APP WITH ECLIPSE ..
DO I NEED TO SET UP THE CLASSPATH ??? FOR THE RESOURCE???
NEED A SOLUTION ......(FULL POINTS DUE TO ........)
LET ME KNOW..
Thax.
_Esam
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get what you are trying to say....
But..
I have to use it as I tried to illustrated it:
How do I put it in the CLASSPATH then? (Using Eclipse:)
_Esam
But..
I have to use it as I tried to illustrated it:
How do I put it in the CLASSPATH then? (Using Eclipse:)
_Esam
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> How do I put it in the CLASSPATH then? (Using Eclipse:)
put it in the same directory as the class file and use the command I posted above
put it in the same directory as the class file and use the command I posted above
ASKER
Eventually I will have to use the custome parser to parse through the XML and get the attributes...
I just want to test that I can at least read it using the getResourceAsStream() - this I have to use :)
_Esam
I just want to test that I can at least read it using the getResourceAsStream() - this I have to use :)
_Esam
> I just want to test that I can at least read it using the getResourceAsStream() - this I have to use :)
See my earlier comment, it shows what you need to do to use getResourceAsStream()
For example if u put it in the same directorory as mClass you would use:
InputStream lConfigFileInputStream =
((Class)mClass)
.getResourceAsStream
("CECEVFeedConfigParameter s.xml");
See my earlier comment, it shows what you need to do to use getResourceAsStream()
For example if u put it in the same directorory as mClass you would use:
InputStream lConfigFileInputStream =
((Class)mClass)
.getResourceAsStream
("CECEVFeedConfigParameter
ASKER
> InputStream lConfigFileInputStream =
((Class)mClass)
.getResourceAsStream
("CECEVFeedConfigParameter s.xml");
Yes -- I just wanted to use the final variable ?
Anyway,
It is working if I put it in the same directory now....
Just getting my expected error now... Happy with it so far..
But trying to put it in a different directory and try it now ... and getting back soon...
Thanks.
_Esam
((Class)mClass)
.getResourceAsStream
("CECEVFeedConfigParameter
Yes -- I just wanted to use the final variable ?
Anyway,
It is working if I put it in the same directory now....
Just getting my expected error now... Happy with it so far..
But trying to put it in a different directory and try it now ... and getting back soon...
Thanks.
_Esam
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>Your binaries and config files should be logically separated so shouldn't be in the same directory
Indeed that's what I was planning but I needed to make sure that for the least I can make it work :)
It's working both ways now.. If I put it in the same directory of the class file or in a different directory relative to the current working directory..
Thanks both...
Coming back shortly with a parsing problem... :)
_Esam.
Indeed that's what I was planning but I needed to make sure that for the least I can make it work :)
It's working both ways now.. If I put it in the same directory of the class file or in a different directory relative to the current working directory..
Thanks both...
Coming back shortly with a parsing problem... :)
_Esam.
:-)
InputStream lConfigFileInputStream = new FileInputStream(CEC_EV_FEE