Hello and thank you for your attention.
I try to use the data as soon as they arrive.
I use the Serializable interface.
I managed to get the last stream with the four data I want,but I need to keep the front last stream and I can't back it up.
Do you have an idea on how to do so.
Have a good day
ArrayList<String> datas = new ArrayList<String>();
datas.add(String.valueOf(askBar.getOpen()));
datas.add(String.valueOf(askBar.getClose()));
datas.add(String.valueOf(askBar.getLow()));
datas.add(String.valueOf(askBar.getHigh()));
File file = new File("/home/jmg/workspace/myFirstDukas/Input.txt");
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(file);
oos = new ObjectOutputStream(fos);
oos.writeObject(datas);
} catch (FileNotFoundException fnfe) {
System.out.println("Could not find file");
fnfe.printStackTrace();
} catch (IOException ioe) {
System.out.println("I/O Exception while writing to file");
ioe.printStackTrace();
} finally {
if (fos != null) {
safeClose(fos);
/
}
}
FileInputStream fis = null;
ObjectInputStream ois = null;
try {
fis = new FileInputStream(file);
ois = new ObjectInputStream(fis);
System.out.println("Affichage des historiques :");
System.out.println("*************************");
datas = (ArrayList<String>) ois.readObject();
for (String i : datas) {
System.out.println(i);
}
} catch (FileNotFoundException fnfe) {
System.out.println("Could not find file");
fnfe.printStackTrace();
} catch (ClassNotFoundException cnfe) {
System.out.println("File format is wrong :(");
cnfe.printStackTrace();
} catch (IOException ioe) {
System.out.println("I/O Exception while reading file");
ioe.printStackTrace();
} finally {
if (fis != null) {
safeClose(fis);
}
}