I have embedded a sqlite database into my java project.
SQLiteConfig config = new SQLiteConfig();
config.enableFullSync(true);
config.setReadOnly(false);
SQLiteDataSource ds = new SQLiteDataSource(config);
ds.setUrl("jdbc:sqlite::resource:"+getClass().getResource("/database/4LifeManager_db").toString());
conexion = ds.getConnection();
Now I want copy that file of the database and to put it in a folder of a computer. I have tried this code:
InputStream in=null;
OutputStream out=null;
try
{
in = getClass().getResourceAsStream("/database/4LifeManager_db");
out = new FileOutputStream(ruta+"/4LifeManager_db");
byte[] buf = new byte[1024];
int len;
while((len = in.read(buf))>0)
{out.write(buf,0,len);}
in.close();
out.close();
}
catch (IOException | HeadlessException e)
{JOptionPane.showMessageDialog(escritorio,"No se pudo extraer archivo\n"+e.toString());}
But when I execute that code, only copy the file without modifications, that is, without the data I deleted, entered or modified. If someone helps me, I will be grateful
Aucun commentaire:
Enregistrer un commentaire