Monday 15 June 2015

java - How to write a point object to a text file -


I am trying to write a list that contains a list of digits in the text file. I have been successful in writing AA method to save the point in the text file However, I'm getting some additional characters in the output

  try {FileOutputStream fileOut = new FileOutputStream (path); ObjectOutputStream Out = New ObjectOutputStream (FileAut); For (int i = 0; i & lt; pointList.size (); i ++) {string s = parseString (pointList.get (i)); Out.writeObject (s); } Out.close (); FileOut.close (); } Hold (IOException i) {i.printStackTrace (); } Private Static String Parasstring (Point P) {String Point = String.value (P.T.T.X)), "+ String.value (PGATT)" ; System.out.println ("string:" + point); Return point; }  

This is a point list

  list & lt; Point & gt; Point list = new arrelist (); PointList.add (new point (100,200)); PointList.add (new point (300,500)); PointList.add (new point (400,200)); PointList.add (new point (100,500)); PointList.add (new point (400,200! [Enter image details here] [1]));  

This writing method is the output of http: //i.stack .imgur .com / hqMDK.png

I think how to get rid of the characters on the first line of production and how to understand t on each line

> Thank you for < /p>

object overputstream writes binary serialization data in the stream This human-readable output Do not have to produce.

If you want to write human-readable, use something instead PrintWriter


No comments:

Post a Comment