On Sunday 30 December 2007 06:22:09 Stephen Bannasch wrote: > At 11:33 PM +0100 12/29/07, Mirko Stocker wrote: > >but I couldn't figure out how to > >open other resources (a file) I put into the jar along my compiled ruby > >class. It would be great if someone could post a solution for this to the > >wiki :) > > I'm working on this also. When I get further I'll post here and add to the > wiki page.
Hm, it didn't work because of a stupid mistake I made.. I tried to use
getClass().getResource(..), but that doesn't work with jars, but this worked
as expected:
input_stream = self.get_class.get_resource_as_stream("/file.txt")
reader =
java.io.BufferedReader.new(java.io.InputStreamReader.new(input_stream))
builder = java.lang.StringBuilder.new
while (ch = reader.read) >= 0
builder.append(ch)
end
reader.close
But I still have to investigate another problem I found, if I have two
compiled files in a jar and one requires the other, it can't find it. Or
maybe I just did something wrong there too :) Is that generally supposed to
work?
Cheers
Mirko
signature.asc
Description: This is a digitally signed message part.
