java - very simple copying a file from my jar -
ok, wanted open pdf file put in jar, needed copy file jar disk, , did following code:
inputstream = jar.class.getresourceasstream("images/lol.pdf"); outputstream os = new fileoutputstream("753951741.pdf"); byte[] buffer = new byte[4096]; int length; while ((length = is.read(buffer)) > 0) os.write(buffer, 0, length); os.close(); is.close();
my question is:how control file created? when execute program it's created under c:/users/buba in advance :)
you can this:
file file = new file("c:/753951741.pdf"); outputstream os = new fileoutputstream(file);
in case file created in c:/
for more information file in java: http://docs.oracle.com/javase/6/docs/api/java/io/file.html#file(java.lang.string)
Comments
Post a Comment