Dukascopy
 
 
Wiki JStore Search Login

Stream live datas serializable
 Post subject: Stream live datas serializable Post rating: 0   New post Posted: Thu 17 Sep, 2015, 08:20 
User avatar

User rating: 0
Joined: Fri 17 Jan, 2014, 17:43
Posts: 16
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);
              }
            }


 

Jump to:  

cron
  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com