Re: (DUDA) Como guardar datos dentro de un jar
Publicado: 10 Jul 2012, 15:08
por orlando9427
Guarda el fichero como recurso desde el builder
Con el Installer solo lees los recursos y los extraes
Saludos!
Re: (DUDA) Como guardar datos dentro de un jar
Publicado: 10 Jul 2012, 16:31
por adwind
Con esto te puedes dar una idea amigo. De como crear un jar y agregarle cosas. Lo demas te dejo lo investigues.
Código: Seleccionar todo
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
/**
*
* @author adwind
*/
public class TestJar {
public TestJar(){
JarOutputStream out=null;
try {
out = new JarOutputStream(new FileOutputStream("dinamic.jar"));
out.putNextEntry(new JarEntry("nota.txt"));
out.write("Este es un elemento".getBytes());
out.closeEntry();
out.putNextEntry(new JarEntry("nota2.txt"));
out.write("Este es un segundo elemento".getBytes());
out.closeEntry();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
out.close();
} catch (IOException ex) {
}
}
}
public static void main(String [] args){
new TestJar();
}
}