ArrayList tempArrayz = new ArrayList();
tempArrayz = (ArrayList) newArray.get(0);
File f = new File("WorkSpace");
f.mkdir();
File f1 = new File(f.getAbsolutePath(), user.getUserName());
f1.mkdir();
File fileo = new File(f1.getAbsolutePath(), user.getUserName() + ".dat");
try {
ObjectOutputStream ou = new ObjectOutputStream(new
FileOutputStream(fileo));
ou.writeObject(tempArrayz);
catch{
(Exception e) {
System.out.println(e.toString());
}
}
Below is the code to read from that and print out the array size
public void readTheFile()
{
boolean stopReading = false;
int numberOfRead = 0;
while (!stopReading) {
try {
numberOfRead++;
File f = new File("WorkSpace");
f.mkdir();
File f1 = new File(f.getAbsolutePath(), user.getUserName());
f1.mkdir(); //make the username folder
File fileo = new File(f1.getAbsolutePath(),
user.getUserName() + counter + ".dat");
System.out.println(oi.readObject());
ObjectInputStream oi = new ObjectInputStream(new
FileInputStream(fileo));
array = (ArrayList) oi.readObject();
System.out.println(array.size());
oi.close();
stopReading = true;
} catch (Exception e) {
if (numberOfRead == 2) {
stopReading = true;
}
}
}
anyone tell me what im doing wrong? When it prints out the array object before assigning it to my input stream it returns
[email protected]
AHhh!! help
~Admin Edit: please use [code] tags like in the example.

New Topic/Question
Reply



MultiQuote



|