On Wed, 23 Feb 2005 12:36:09 +0100
Ines Pfauch <[EMAIL PROTECTED]> wrote:
> Hi,
>
> At first I am sorry, because I think my problem does not belong very
> good to this mailing list.
>
> For the last 20 weeks I was creating an java add-on for OOo. Now three
>
> days are left and my installer does not what it should. Therefore I
> hope, someone can help me:
>
> I have created a self-executing jar file with some class files, which
> contains the GUI and the execution of pkgchk. It also contains the zip
> file, which I want to deploy with pkgchk.
>
> But when I try to copy the zip to some directory I get
> filenotfoundexception. Is there an other way to extract a file from
> within the self-executing jar (without using a jar command) to any
> directory...?
>
Hi Ines,
if I understand you correct and you want to copy the embeded zip-file.
import java.io.*;
public class ...
...
public void copy(String destination){
try {
//getting the zip-file from the jar-archiv
BufferedInputStream in = new
BufferedInputStream(this.getClass().getClassLoader().getResourceAsStrea
m("resources/my.zip"));
//where it should be stored
BufferedOutputStream out = new BufferedOutputStream(new
FileOutputStream(destination));
//copy from in to out
byte[] bytes = new byte[1024];
int len = -1;
while ((len = in.read(bytes)) > -1) {
out.write(bytes, 0, len);
}
in.close();
out.flush();
out.close();
} catch (IOException e) {
//handle this
}
}
}
untested (maybe typos).
Best Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]