Forums Register Login

simple search v/s classpath search

+Pie Number of slices to send: Send
What is the difference b/w these two:





What I think is, in first one, you have to give absolute path of file and in second case, JVM will search file into classpath.

Is there any other difference???

Why in second case, JVM searches file into classpath???

Please solve my doubt.

Thanks a lot.
+Pie Number of slices to send: Send
 

Originally posted by rathi ji:
Why in second case, JVM searches file into classpath???



Why? Just because that's how it works. The question is meaningless. You are comparing two completely different pieces of code. There's no reason why they should be doing the same thing.
+Pie Number of slices to send: Send
 

Originally posted by Jesper de Jong:


Why? Just because that's how it works. The question is meaningless. You are comparing two completely different pieces of code. There's no reason why they should be doing the same thing.



They both are creating File object, only the process of creating object is different.

There is one more thing I have heard about is getResourceAsStream(). I am very confuse, how they works??? Where we should use what???

Thanks.

Have you no shame? Have you no decency? Have you no tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 785 times.
Similar Threads
K&B Chapter 10 Self Help Question 9
Help with java input file
file name loop
Eclipse classpath question
Check the file/found or not
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:12:22.