i a problem with java and how to import to file 1024000 numbers.
I created and application that reads data from port and store every number to a file as ascii character.
but it takes too long. java supose to be quicker. what should i change? should i use other libriries ? not FileOutputStream ?
as i tested now in 20 minuts i had 100.000 in my file....
Thank you

```
public void serialEvent(SerialPortEvent evt) {  

   if (evt.getEventType() == SerialPortEvent.DATA_AVAILABLE)  
   {  
       try  
       {  
           int singleData = input.read();  

           if(index<=1024000)  
           {                 
               if(index==1024000 && singleData==42)
               {
                   logText = "End of data. "+index+" data received ";  
               }
               else
               {  
                   if (singleData != NEW_LINE_ASCII)  
                   {  
                       //  logText = Integer.valueOf(singleData).toString()+"\n";  
                       index++;  
                   }  

                   writeFile(singleData, fileName, false);  
               }         
           }  
       }
       catch (Exception e)
       {  
           logText = "Failed to read data. (" + e.toString() + ")";  
       }  
    }  
}  

public void writeFile(int data, String fileName, boolean endOfFile) throws IOException {  

    FileOutputStream xfos = new FileOutputStream(fileName,true);  
    DataOutputStream xdos = new DataOutputStream(xfos);  

    xdos.writeBytes(Integer.toString(data)+"\n");   // writes Ascii  

    xdos.close();  
}  

```