Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26
  1. #21
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    But what that's saying is that you can't use the same String value with getSystemResource as you do with getResourceAsStream since the latter does some conversion work on it.

    Why did you decide to go via the ClassLoader rather than the more normal Class methods?

  2. #22
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default

    It's basically the first thing that popped up when I searched for how to access files in JARs, leaving out the applet bit. It worked for the application, so I kept it there. Kinda considering switching it over to what the applet uses though, to keep it consistent.

  3. #23
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    class.getResourceAsStream() is the standard.
    I don't think I've ever seen the ClassLoader one used in any project I've worked on.

  4. #24
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    One or the other of us needs an avatar...:)

  5. #25
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default

    I'm all for using standards, so class.getResource() etc it is then! Seems to work just as well, both for images and normal files (and using the same path names to boot, which is always a positive).

  6. #26
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default

    Y'know, the thought did cross my mind when I first noticed you that "okay, this might get confusing" :)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. reading files from online applet
    By mickmos in forum Java Applets
    Replies: 0
    Last Post: 12-02-2010, 02:21 AM
  2. Reading external text files from an Applet
    By Arnold in forum New To Java
    Replies: 2
    Last Post: 01-07-2010, 07:43 PM
  3. Replies: 0
    Last Post: 02-26-2009, 04:13 AM
  4. Applet - reading text files packed into JAR file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 10:15 AM
  5. Reading/Writing files through Applet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-15-2007, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •