0

Trying to use

System.getProperty("user.home/myfile.txt") 

getting NullPointerException

Using String path

 String("/Users/user/myfile.txt") 

everything works well.

Need universal way of files location. Not everyone have the same path :)

I'm on MacOSX 10.11. java 8

Thanks

1
  • First of all, debugging questions do not belong on Programmers.SE, they should go on StackOverflow. Secondly, the reason you're getting an error is because there is no "user.home/mytextfile.txt" property defined in the System. You will need to combine the "user.home" property with your filename string to get the path. Commented Oct 26, 2015 at 13:36

1 Answer 1

1
System.getProperty("user.home/myfile.txt") 

There is no system property called user.home/myfile.txt what you probably mean is

System.getProperty("user.home") + "/myfile.txt"; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.