I am receiving data from the serial port and I want to write the data to a file. The problem is that the program is overwriting the data at the same place in the file. For example it writes 0xAA and then 0xBD at the same place and when I open the file to read it in text edit then I find only one number in the file. How can I write the numbers one after another? jess
public class Loading {
public static void writeFile(String fileName,int bytes) {
FileOutputStream fo = null;
File file;
try {
file = new File("C:/dar.txt");
fo = new FileOutputStream(file);
if (!file.exists())
{
file.createNewFile();
}
//StringUtils.getHexString((byte) bytes);
fo.write((byte) bytes);
System.out.println(getHexString (bytes));
}
catch (Exception e) {
System.out.println("writeFile exception: " + e.getClass().getName() + " " + e.getMessage());
}
finally {
if (fo != null) {try {fo.close();} catch (Exception ex) {}}
}
}