Stream Closed when accessing a jar file
I am writing an applet that reads text files from a folder in a jar file in order to get the information it needs. My current code for getting the contents of the jar file is:
publicvoid getStuff(String folder){
for(int i=0; i<stuff.length; i++){
ArrayList><ArrayList> holder=new ArrayList<ArrayList>();
try{
int num=i+1;
URL url =new URL("jar:http://www.geocities.com/bbubenheim/Grapher.jar!/"+folder+"/"+num+".txt");
JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
BufferedReader in=new BufferedReader(new InputStreamReader(jarConnection.getInputStream()));
System.out.println(in);
String str="";
while ((str = in.readLine()) !=null){
ArrayList<String> line=new ArrayList<String>();
while(str.contains(",")){
String temp="";
temp=str.substring(0, str.indexOf(","));
// System.out.println(temp);
str=str.substring(str.indexOf(",")+1);
line.add(temp);
}
if(!str.contains(",")){
String tmep="";
tmep=str;
line.add(tmep);
}
holder.add(line);
}
stuff[i]=holder;
in.close();
}catch (IOException e){
System.out.println(e);
e.printStackTrace();
}
}
}
it works in NetBeans ("tmep" is the actual variable name, "temp" got boring), but when i try to put it in an html file, whose code is:
<applet code=Graph.class archive="InteractiveGrapher.jar" height=600 width=1000>
</applet>
(InteractiveGrapher is the jar with all the class files)., I get this error, which happens at the "BufferedReader in= new BufferedReader(new InputStreamReader(jarConnection.getInputStream()));" line:
java.io.IOException: Stream closed.
at java.net.PlainSocketImpl.available(Unknown Source)
at java.net.SocketInputStream.available(Unknown Source)
at java.io.BufferedInputStream.available(Unknown Source)
at sun.net.www.http.ChunkedInputStream.readAheadNonBlocking(Unknown Source)
at sun.net.www.http.ChunkedInputStream.readAhead(Unknown Source)
at sun.net.www.http.ChunkedInputStream.available(Unknown Source)
at sun.net.www.MeteredStream.available(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
at GetData.getStuff(GetData.java:48)
at GetData.<init>(GetData.java:35)
at Graph.<init>(Graph.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Is this geocities locking me out? It works from NetBeans so i thought the permissions or whatever it needs to access the jar file would be the same from a browser, any ideas?

