polkadot
asked on
URGENT! java.lang.NullPointerException with File object
why would this give me java.lang.NullPointerExcep tion ?
File directory = new File("C:/Temp");
File[] fileList = directory.listFiles();
is there something else I should look for in the code?
File directory = new File("C:/Temp");
File[] fileList = directory.listFiles();
is there something else I should look for in the code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
C:/Temp will work fine (as long as the dir exists), I just tested it.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
:/
C:/Temp is a directory ... and it works that way ... so I'll give you all good grades :)
but not this way:
public class A{
File directory;
public A(File d)
{ directory = d; }
public void M()
{ File[] fileList = directory.listFiles();}
can you explain why, that when I want it to remeber the directory in the method, It forgets ?
C:/Temp is a directory ... and it works that way ... so I'll give you all good grades :)
but not this way:
public class A{
File directory;
public A(File d)
{ directory = d; }
public void M()
{ File[] fileList = directory.listFiles();}
can you explain why, that when I want it to remeber the directory in the method, It forgets ?
ASKER
I have another 500 pt question, maybe you can help?
https://www.experts-exchange.com/questions/21136459/help-a-vector-of-hashtables.html
https://www.experts-exchange.com/questions/21136459/help-a-vector-of-hashtables.html
>>This may resolve the problem.
It won't
>>can you explain why, that when I want it to remeber the directory in the method, It forgets ?
Maybe - if you post the rest of the code for class A
It won't
>>can you explain why, that when I want it to remeber the directory in the method, It forgets ?
Maybe - if you post the rest of the code for class A
You should post your solution, not just comment CEHJ.
>>You should post your solution
As i mentioned, polkadot will have to post more code
As i mentioned, polkadot will have to post more code
ASKER