objectoutputstream

java.io.EOFException while writing and reading froma servlet

两盒软妹~` 提交于 2019-11-27 06:24:45
问题 I have the following code on the applet side: URL servlet = new URL(appletCodeBase, "FormsServlet?form=requestRoom"); URLConnection con = servlet.openConnection(); con.setDoOutput(true); con.setDoInput(true); con.setUseCaches(false); con.setRequestProperty("Content-Type", "application/octet-stream"); ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream()); out.writeObject(user);//user is an object of a serializable class out.flush(); out.close(); ObjectInputStream in = new

java.io.StreamCorruptedException: invalid type code: 00

♀尐吖头ヾ 提交于 2019-11-27 05:34:57
So basically im writing a client-server multiplayer game. I have a SeverCommunicationThread that creates a gameThread if he receives a RequestForGame creates a gameThread. When i send a RequestForGame exception is thrown java.io.StreamCorruptedException: invalid type code: 00 I assume it's because both threads try to read the same ObjectInputStream, I don't have much understanding about how it works, i just know how to use it. Could you help me understand what's the problem and how to fix it? Thanks :) public class ServerCommunicationThread extends Thread{ private Socket connectionSocket;

'java.io.ObjectOutputStream' is deprecated - an error in Intellij IDEA

为君一笑 提交于 2019-11-26 23:18:31
I have this code: import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Date; public class EmployeeProcessor { public static void main(String[] args) { Employee employee = new Employee(); employee.lastName = "Smith"; employee.firstName = "Adam"; employee.id = 123456789; employee.salary = 50000; try(FileOutputStream fileOutStr = new FileOutputStream("Employee.ser"); ObjectOutputStream objectOutStr = new ObjectOutputStream(fileOutStr)) { objectOutStr.writeObject(employee); System.out.println("An employee is externalized into the file

Sending the same but modifed object over ObjectOutputStream

余生长醉 提交于 2019-11-26 15:31:01
I have the following code that shows either a bug or a misunderstanding on my part. I sent the same list, but modified over an ObjectOutputStream. Once as [0] and other as [1]. But when I read it, I get [0] twice. I think this is caused by the fact that I am sending over the same object and ObjectOutputStream must be caching them somehow. Is this work as it should, or should I file a bug? import java.io.*; import java.net.*; import java.util.*; public class OOS { public static void main(String[] args) throws Exception { Thread t1 = new Thread(new Runnable() { public void run() { try {

java.io.StreamCorruptedException: invalid type code: 00

拈花ヽ惹草 提交于 2019-11-26 11:38:20
问题 So basically im writing a client-server multiplayer game. I have a SeverCommunicationThread that creates a gameThread if he receives a RequestForGame creates a gameThread. When i send a RequestForGame exception is thrown java.io.StreamCorruptedException: invalid type code: 00 I assume it\'s because both threads try to read the same ObjectInputStream, I don\'t have much understanding about how it works, i just know how to use it. Could you help me understand what\'s the problem and how to fix

'java.io.ObjectOutputStream' is deprecated - an error in Intellij IDEA

自作多情 提交于 2019-11-26 08:37:52
问题 I have this code: import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Date; public class EmployeeProcessor { public static void main(String[] args) { Employee employee = new Employee(); employee.lastName = \"Smith\"; employee.firstName = \"Adam\"; employee.id = 123456789; employee.salary = 50000; try(FileOutputStream fileOutStr = new FileOutputStream(\"Employee.ser\"); ObjectOutputStream objectOutStr = new ObjectOutputStream

Sending the same but modifed object over ObjectOutputStream

家住魔仙堡 提交于 2019-11-26 04:28:38
问题 I have the following code that shows either a bug or a misunderstanding on my part. I sent the same list, but modified over an ObjectOutputStream. Once as [0] and other as [1]. But when I read it, I get [0] twice. I think this is caused by the fact that I am sending over the same object and ObjectOutputStream must be caching them somehow. Is this work as it should, or should I file a bug? import java.io.*; import java.net.*; import java.util.*; public class OOS { public static void main

Appending to an ObjectOutputStream

假如想象 提交于 2019-11-25 23:02:48
问题 Is it not possible to append to an ObjectOutputStream ? I am trying to append to a list of objects. Following snippet is a function that is called whenever a job is finished. FileOutputStream fos = new FileOutputStream (preferences.getAppDataLocation() + \"history\" , true); ObjectOutputStream out = new ObjectOutputStream(fos); out.writeObject( new Stuff(stuff) ); out.close(); But when I try to read it I only get the first in the file. Then I get java.io.StreamCorruptedException . To read I