Results 1 to 1 of 1
Thread: writing an object
- 02-05-2011, 06:05 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
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
-
Insert class file as object in a table & read the object from the blob.
By facemeguru in forum New To JavaReplies: 1Last Post: 02-02-2011, 06:11 PM -
writing an object of JFrame to disc
By sakshamkum in forum Advanced JavaReplies: 9Last Post: 09-02-2010, 03:15 PM -
Create object of unknown class, based on existing object
By Zack in forum New To JavaReplies: 2Last Post: 06-22-2010, 04:29 AM -
Im writing to a file and i want to skip lines while writing to a text file.
By Broden_McDonald in forum New To JavaReplies: 1Last Post: 02-27-2010, 01:29 AM -
how to pass an arraylist from an object back to the parent object that it was created
By george_a in forum New To JavaReplies: 1Last Post: 03-04-2009, 06:14 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks