Why does this keep overwriting?

Page 1 of 1

1 Replies - 112 Views - Last Post: 27 October 2014 - 09:59 AM Rate Topic: -----

#1 CyperGhost  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 02-September 13

Why does this keep overwriting?

Posted 27 October 2014 - 09:58 AM

So I am calling this method several times and trying to write multiple records to a file. Problem is that every time I call the method it overwrites the file from before and doesn't add it. Can someone please help me?


	public void fileWriterMethod() throws IOException{
		
		RandomAccessFile raf = new RandomAccessFile(filename, "rw");
		
		raf.writeInt(id);
		raf.writeInt(existingMileage);
		raf.writeInt(gasCost);
		raf.writeInt(ndays);
		raf.writeInt(rate);
		raf.writeInt(totalCharge);
		raf.writeInt(discount);
		raf.writeInt(tax);
		raf.writeInt(netCharge);
		raf.writeInt(returnMileage);
		raf.writeBytes(carName + "\r\n");
		
		//Closing the stream
		
		raf.close();
		
	}


Is This A Good Question/Topic? 0
  • +

Replies To: Why does this keep overwriting?

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,257
  • Joined: 27-December 08

Re: Why does this keep overwriting?

Posted 27 October 2014 - 09:59 AM

I merged the thread you opened a minute ago with your thread from yesterday (and responded). It's at the top of the forum, so it should be easy to find. Please don't duplicate post.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1