1 Replies - 1431 Views - Last Post: 21 August 2007 - 04:47 PM Rate Topic: -----

#1 Cypherz00   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 20-August 07

My file input output problem

Posted 20 August 2007 - 07:23 PM

ok a new even simpler question. The code below is meant to create a folder, output information into that folder, and write and array into it.
		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.

Is This A Good Question/Topic? 0
  • +

Replies To: My file input output problem

#2 William_Wilson   User is offline

  • lost in compilation
  • member icon

Reputation: 207
  • View blog
  • Posts: 4,812
  • Joined: 23-December 05

Re: My file input output problem

Posted 21 August 2007 - 04:47 PM

what does the code do? does it create the directory or the file? does it save the data? is it a saving or retrieval error? more info if you want help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1