How to write object data into text file
Posted on 2006-04-08
I have 3 values which I want to write into a text file (.dat). The data is read from a Map object and also an array of Integer.
The code snippet is as follows:
Pixel freqList = new Pixel[frequent];
Iterator iter = data.iterator();
int colValue = new int[frequent];
int index = 0;
Map.Entry sortedEntries = (Map.Entry)iter.next();
freqList[index] = (Pixel) sortedEntries.getKey();
colValue[index] = freqList[index].getColourValue();
textPanel.println(" (" +sortedEntries.getKey()+ ")\t\t" + colValue[index] + "\t\t" +sortedEntries.getValue());
The three values I want to write are from sortedEntries.getKey(), sortedEntries.getValue() and colValue[index].
I have looked around but found nothing which can help me. Anyway, out of curiousity, do I need to use ObjectOutputStream?
Can anyone help me?