This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes getting stream for resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting stream for resource" Watch "getting stream for resource" New topic
Author

getting stream for resource

saravanan ragunathan
Ranch Hand

Joined: Aug 02, 2010
Posts: 84
when i download the file i tried two methods to get the input stream for resource
first one is


second one is


in this code i had to specify full pathname...other than that..both works well
but which one is better ..for what?


"I Love Java Ranch"
T. Huy Nguyen
Ranch Hand

Joined: Nov 02, 2010
Posts: 57
Hi,

IMO, the 1st one is better. The 2nd one ties you to a specific type of file system, and requires an absolute path. If your server location change, that code may not work anymore. In addition, because it uses the normal Java IO, it can open any file in your server - to me, it's a security risk.


My material for SCJP (2008), SCWCD (2010), SCBCD (2010). About me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting stream for resource
 
Similar Threads
Loading a property file from a fixed folder in the filesystem
file download method
Favorite upcoming feature?
Try catch confusion
problems in downloading epub files