Results 1 to 1 of 1
  1. #1
    richman92 is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default writing an object

    Hi.

    I have got a problem with writing an object. I would like to save a hashmap with highscores on a server, but it does not work. It throws java.net.UnknownServiceException. Any better solutions are welcome.

    public class ListOfPlayers implements Serializable {

    public void save() {

    try {

    URL file = new URL("file:game.bin");
    URLConnection connection = file.openConnection();
    connection.setDoOutput(true);
    ObjectOutputStream vystup = new
    ObjectOutputStream(connection.getOutputStream());
    vystup.writeObject(players); // players = HashMap
    vystup.close();

    } catch(Exception e) {

    System.out.println(e);

    }
    }
    }
    Last edited by richman92; 02-05-2011 at 06:10 PM. Reason: Translation

Similar Threads

  1. Replies: 1
    Last Post: 02-02-2011, 06:11 PM
  2. writing an object of JFrame to disc
    By sakshamkum in forum Advanced Java
    Replies: 9
    Last Post: 09-02-2010, 03:15 PM
  3. Replies: 2
    Last Post: 06-22-2010, 04:29 AM
  4. Replies: 1
    Last Post: 02-27-2010, 01:29 AM
  5. Replies: 1
    Last Post: 03-04-2009, 06:14 PM

Tags for this Thread

Posting Permissions

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