Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

simple search v/s classpath search  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15859
80
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!