problem about objectinputstream-Collection of common programming errors
-
akafortes
java android objectinputstream
I have created a java server and an Android client and the client asks data from the server using a custom class “Message” I’ve created. I’ve made a JAR file with this Message class and used it as an external referance in both the server and the client.Message Class:import java.io.Serializable;public class Message implements Serializable {private static final long serialVersionUID = 1L;public String sender, content, type;public Message(String sender, String type, String content) {this.sender = s -
Andrew Thompson
java serialization io nullpointerexception objectinputstream
I’m writing a server-client application with Java, on Android and Windows. I want to send the user’s information (Username and password) to the server for verification. client sends the object containing the information, but the server doesn’t receive it! here is the Object class:package Model;import java.io.Serializable;public class StringObject implements Serializable {private static final long serialVersionUID = 1L; private String Username=null; private String Password=null;public void setPas -
prmatta
java multithreading executorservice objectinputstream
I have a thread that sits and reads objects off of an ObjectInputStream:public void run() {try {ois = new ObjectInputStream(clientSocket.getInputStream());Object o;while ((o = ois.readObject()) != null) {//do something with object}} catch (Exception ex) {//Log exception} }readObject does not throw InterruptedException and as far as I can tell, no exception is thrown when this thread is interrupted. How do I stop this thread? -
Marc-Andre
java objectinputstream objectoutputstream eofexception
I wrote some client – server program, that shares data but at server side i got EOFException after reciving data. I tried to fix it on my own but it is hard to find own errors.The error is caused by this line: Message command =(Message) serInputStream.readObject();Here is some output from server:java.io.EOFExceptionat Java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2577) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1315) at java.io.ObjectInputStr -
Mike Pennington
java sockets networking tcp objectinputstream
I’m trying to read an object from client program over tcp. As you can see in this line I created objectInput:ObjectInputStream objectInput = new ObjectInputStream(incoming.getInputStream());And then read my input from the other program. It used to work fine until i made minor changes to clean up the program. Personally Assume I added objectInput.clsoe();My question is, After reading the object should I close the objectInputStream or Keep remain without close? Should I close it straight away afte -
Greg Butzi
java serialization tcp objectoutputstream objectinputstream
I’ve serialized some objects so I can convert them to byte arrays for a TCP packet. When I send the objects from the server program to the client program, there are no issues and it works fine. However, even though the code between the server and client is identical, when I try to send objects from the client to the server I get an invalid header.Here are the objects I’m serializing:public static byte[] serialize(Hand c) throws IOException{ByteArrayOutputStream baos = new ByteArrayOutputStream() -
mithun1538
java objectoutputstream objectinputstream eofexception
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 ObjectInput -
Alexander Fragotsis
java client-server objectinputstream
my code is thistry{//Connect to the login serversocket = new Socket(hostName , 15000);out = new ObjectOutputStream(socket.getOutputStream());input = new ObjectInputStream(socket.getInputStream());.. //perform the login , if the login succeed make answ=1;}catch (UnknownHostException e) {System.err.println(“Unknown host: ” + hostName);StatusLabel.setText(“Unknown host”);}catch (ConnectException e) {System.err.println(“Connection refused by host: ” + hostName);StatusLabel.setText(“Connection refuse
Originally posted 2013-12-02 20:59:40.