Results 1 to 4 of 4
  1. #1
    cassysumandak is offline Member
    Join Date
    Mar 2009
    Posts
    38
    Rep Power
    0

    Default Save PolygonLinked list in Notepad.txt

    I save a triangle polygon vertices in Notepad.txt. But when I open the Notepad file manually, I got weird symbol in the file.
    Is there any way that when I open the Notepad, I get the vertices (co-ordinates) of the polygon instead of symbol?

    Java Code:
    ... 
    java.util.List<Polygon> triangles = new LinkedList<Polygon>();
    String pathname = "eyemovement.txt";
    ...
    int[] xs = { startDrag.x, endDrag.x, midPoint.x };
    int[] ys = { startDrag.y, startDrag.y, midPoint.y }; 
    triangles.add(new Polygon(xs, ys,3));
    
    ...
    public void actionPerformed(ActionEvent e) {
       if(e.getSource() == saveBtn){
          try {
          FileOutputStream fos = new FileOutputStream(pathname);
          ObjectOutputStream oos = new ObjectOutputStream(fos);
          oos.writeObject(triangles);
          oos.flush();
          oos.close();
          fos.close();
      }
      catch (Exception ex) {
        System.out.println("Trouble writing display list vector");
      }
    }

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    6

    Default

    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(triangles);
    You are using ObjectOutputStream, means the serialized object is written to the file.

    If you wish to see the text data in notepad, probably you can use PrintWriter.

  3. #3
    cassysumandak is offline Member
    Join Date
    Mar 2009
    Posts
    38
    Rep Power
    0

    Default

    How can I store the Linked List data in Notepad.txt with the following format?

    20 40 30 vertices of Xs of triangle 1
    20 20 30 vertices of Ys of triangle 1

    100 120 110 ..triangle 2
    100 100 110

    60 80 70 triangle 3
    60 60 70
    Last edited by cassysumandak; 10-01-2009 at 02:55 AM.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Please stick to one thread for the same problem.
    Are you trying to confuse people trying to help you?

Similar Threads

  1. How can i save the data Internally(auto save)
    By Rama Koti Reddy in forum AWT / Swing
    Replies: 2
    Last Post: 11-01-2010, 09:31 PM
  2. problem with notepad
    By munish in forum Advanced Java
    Replies: 7
    Last Post: 08-30-2009, 12:53 PM
  3. Load file in GUI instead of notepad
    By Kruptein in forum AWT / Swing
    Replies: 1
    Last Post: 08-08-2009, 06:57 PM
  4. NotePad
    By whosadork in forum New To Java
    Replies: 10
    Last Post: 10-03-2008, 08:44 PM
  5. Notepad or IDE?
    By Eranga in forum Other IDEs
    Replies: 30
    Last Post: 09-22-2008, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •