objectinputstream « API « Java I/O Q&A





1. Java - resolve ObjectInputStream    stackoverflow.com

Please tell me how to differentiate objects from ObjectInputStream.Like whether it is String , Image or etc...?

2. Shouldn't ObjectInputStream extend FilterInputStream?    stackoverflow.com

The block quotes are from the Java Docs -

A FilterInputStream contains some other input stream, which it uses as its basic source of data, possibly ...

3. JApplet gets a java.lang.OutOfMemoryError exception on ObjectInputStream.readObject(Unknown Source)    stackoverflow.com

I've written a JApplet that that connects to a server. On connecting it receives an ImageIcon. On receipt it send a String "I" to the server to confirm. This signals the ...

4. FileInputStream and ObjectInputStream    stackoverflow.com

I have to read in a file using these classes. I don't really understand how they work.

FileInputStream inFile = new FileInputStream(fileName);
ObjectInputStream inStream = new ObjectInputStream(inFile);
car = (Car)inStream.readObject();
If car is a class, ...

5. Could ObjectInputStream.readObject() return null?    stackoverflow.com


my question is: could ObjectInputStream.readObject() method return null? Thank you

6. ObjectInputStream happy with FileInputStream, not happy with getResourceAsStream    stackoverflow.com

I have some pretty standard code which takes in a serialized object from a stream, which bascially looks like this:

  Object getObjectFromStream(InputStream is) {
    ObjectInputStream ois = ...

7. Exception.getCause() returning null when trying to find the source of an exception    stackoverflow.com

why does System.out.println(e.getCause()); gives null? And can store whole hash-set collection like this?

private void saving() throws IOException, ClassNotFoundException {
            ObjectOutputStream out ...

8. Load saved game from file using ObjectInputStream    bytes.com

@Humakt Care to elaborate a bit on the 'bit of a problem'? Doesn't it read the object from the Stream? Make sure that all your member objects of a Game object ...

9. How to read a txt file with ObjectInputStream    bytes.com

An ObjectInputStream loads objects and therefore the corresponding file contains binary data! But a text file contains text and no binary data. If you want to read a text file, use ...





10. Hanging ObjectInputStream    coderanch.com

Hey there, I have a question about the order of Input and Output. If you change the order of the commented lines the below code doesn't work. Why? try { client = new Socket (InetAddress.getLocalHost(), 4321); display.append( "Connected to: " + client.getInetAddress().getHostName() ); output = new ObjectOutputStream(client.getOutputStream() ); //DON'T CHANGE THIS ORDER input = new ObjectInputStream( client.getInputStream() ); //INPUTSTREAM MUST BE ...

11. ObjectInputStream    coderanch.com

I am trying to read a file and skip some bytes ... using "skipBytes" method, but it always skips zero bytes irrespective of what the argument is.... here is the code. long fp...(from some other method) fos = new FileInputStream("emp.ser"); bos = new BufferedInputStream(fos); oos = new ObjectInputStream(fos); try{ int avail = oos.available(); System.out.println("avail = " + avail); int b = ...

13. exp in ObjectInputStream    coderanch.com

There are times when you want to write out an object so that you can preserve it's current state. For an example, suppose you had a long application process and you had a class that stores all of the data the user is entering. Then when they are complete, you enter it into a database. Well if a user was to ...

14. why ObjectInputStream is not a FilterInputStream?    coderanch.com

Hi guys, I'm wondering why ObjectInputStream is not the subclass of FilterInputStream like DataInputStream? Since it provides the similar extended functionality to the InputStream and it also takes InputStream as a constructor parameter, I think it's a typical applicable case of "wrapper". Did i miss something subtle? Any reply would be greatly appreciated. Regards, James

15. how to know when ObjectInputStream do not have anything to read ?    coderanch.com

Hi Guys, How to know when InputStream(say ObjectInputStream) reaches End of Stream ? What I'm doing is calling readObject() in an infinite loop. So, if there is nothing to be read from outputstream, it throws EOFException. So, I want to know if there is anything to be read in stream or not before invoking readObject() method. If yes, only than I ...

16. reseting an objectinputstream    coderanch.com





17. objectInputStream efficiently    coderanch.com

18. end of ObjectInputStream    coderanch.com

How can you read all the objects of a file written by an ObjectOutputStream? I tried the following code but it didn't work Thanks for any suggestions ! try { ObjectInputStream input = new ObjectInputStream(new FileInputStream("RESERV.txt")); while( input.readObject() != null){ Reservatie reservatie = (Reservatie) input.readObject(); vulMatrixReservatieOp(reservatie.kamernummer,reservatie.datumAankomst,reservatie.aantalDagen); } input.close(); } catch (FileNotFoundException e) { System.out.println("Het opgegeven bestand werd niet gevonden"); } catch ...

19. ObjectInputStream??????    coderanch.com

20. ObjectInputStream error. BIG error. BIG help required ;)    coderanch.com

Hi, guys! I saw there were couple of similar topics already but they didn' help me, so here's my problem: I am writing a program that will interrogate a server. I haven't written the server (nor can I touch it to modify it, coz it's integrated in a commercial application), however it is installed on my machine (Win XP). I know ...

21. ObjectInputStream    coderanch.com

22. ObjectInputStream    coderanch.com

hi i have a client server program. i can send and recieve text fine. i am trying to create a function that is able to send an image object. i create and objectoutputstream and it sends it properly however when the server recieves it,it prints out a lot of garbage which i thikn is the object. i dont want it to ...

23. ObjectInputStream wrapped in FileInputStream Consuming lot of Memor    coderanch.com

Hi all, Problem: Reading objects from a large file approx 400MB.The file contains 1000's of objects.While reading from files lot of memory is consumed and i finally end up getting Out Of memory. I was facing this problem while writing the same objects to the above mentioned file.This time i had an option to reset my ObjectOutput Stream and thus make ...

24. ObjectInputStream timing out when created    coderanch.com

Hello All! Does anyone know why the following is happening? When creating an ObjectInputStream, the call seems to block forever. If I set a timeout on the socket first, I get a "java.net.SocketTimeoutException: Read timed out" exception thrown. Here is the code: // set the timeout for the socket theClientSocket.setSoTimeout(100); serverInputStream = new ObjectInputStream(theClientSocket.getInputStream()); If I comment out the setSoTimeout line, ...

25. ObjectInputStream problem    coderanch.com

26. SOAPMessage through ObjectInputStream    coderanch.com

Anybody know what the problem is with SOAPMessage? I can pass Document, String, and custom objects with out.writeObject(), in.readObject, just fine. If a SOAPMessage is an XML document, it seems like it should be just as successful as a Document. But I get serialization and eof errors when I try to do it with a SOAPMessage. I'm not using soapMsg.writeTo() and ...

27. ObjectInputStream problems    coderanch.com

hi i am having a problem with the ObjectInputStream. I am trying to send a serializable object using socket but the problem with the ObjectInputStream , the ObjectOutputStream is working fine ,the exception is 'null' so how can i send and receive a serializable object over a Socket. thx for any help

28. ObjectInputStream problem    coderanch.com

Hi Erre, Put in some println statements so you can see what values the important variables have at certain stages. Write them with your expected value too, like this: System.out.println("int i, expected 17, actually is: " + i); Then when you find a variable whose value isn't what you expect, start tracking backwards to find out why. That's the right way ...

29. ObjectInputStream creating OutOfMemoryError    coderanch.com

Help. So I'm writing a network application that receives live streaming data from another server. The other server (not in my control) sends it via serialized objects and, I believe, my only way of reading these is to use the ObjectInputStream and ObjectOutputStream. My issue is that I'm getting a large number of objects over time and I notice two things ...

30. How to identify the end of an ObjectInputStream    coderanch.com

I want to get the serialized objects in a file to a vector.( For a library system for an assignment) But I didn't come across a good way to identify the end of the ObjectInputStream. What is the condition I must add for the while loop in the following code. Here is a sample code: import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; ...

31. ObjectInputStream peek    coderanch.com

Hi Ernest, So basically what I am doing is a merge sort. I have separate file chunks and I need to "peek" at the first record(object) of each file and then return the smallest one. I only want to advance the file pointer in file where the smallest record was found. Does this help? Thanks, AMD

32. Outofmemory Error in ObjectInputStream    coderanch.com

Hi all In our application we are Serializing the Object from one process (JVM) and deserializing the same Object from another process(JVM). Both serialization and deserialization will happen concurrently from Different JVM. We are often getting OOM while de-serialization of the Object. We are using jdk 1.4 for compilation and Jre 1.6 for Running the JVM. We have allocated 512Mb for ...

33. Shouldn't ObjectInputStream also be a (sublass of) FilterInputStream?    coderanch.com

I am appearing for my SCJP exam soon, and so was brushing up on my Java basics when I bumped into this tricky question. Hope someone in here can shed some light on it. From what I understand, An ObjectInputStream basically lets you read a byte version(from an underlying stream) of an Object written by a corresponding ObjectOutputStream. A FilterInputStream lets ...

34. ObjectInputStream does not initialize    java-forums.org

Hi all. I have a client that is supposed to communicate with the server using objects. However, my ObjectInputStream fails to initialize, and blocks. I included the class below, but, unfortunately, it does not compile. I'll try to make a SSCCE, but it could be difficult. Java Code: import java.io.*; import java.net.*; import javax.swing.*; //The next two classes are my own ...

35. ObjectInputStream (FileInputStream? kinda lost)    java-forums.org

Hello, I am trying to fill two textboxes with information contained in a .txt file like such "java","slang for coffee" "hangman","the name of the game" (on a line below would be another combination of word\hint) and separate the two words into separate text boxes and be able to navigate through each combination in order to choose one of them to start ...

36. ObjectInputStream issue    java-forums.org

public Thing[] load (){ FileInputStream fis = null; Thing[] loadData ; try { fis = new FileInputStream("t.tmp"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } ObjectInputStream ois; try { ois = new ObjectInputStream(fis); Thing [] loadData = (Thing[])ois.readObject(); ois.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return loadData;

37. Help with ObjectInputStream    forums.oracle.com

38. NotActiveException when Using ObjectInputStream    forums.oracle.com

I have written this piece of code for serialization and de-serialization. I have a class called Ser15OBJSTRTut3 ,which i have to serialize along with class Animal which does not implement the Serializable interface.The Animal class instance is instantiated in the Ser15OBJSTRTut3 constructor. Hence i have written a utility method which writes the necessay using defaultWriteObject() and the one i need using ...

39. ObjectInputStream Issue    forums.oracle.com

Hi all, I came across an issue ObjectInputStream class. If you (and dont ask me why) require to transmit the class Integer, which is wrapping the int value of -1, then what I believe happens is the ObjectInputStream reads the -1 from an InputStream.read() call.. however InputStream.read() returns -1 when the stream closes. So when the ObjectInputStream sees -1, it ends ...

40. ObjectInputStream with large files?    forums.oracle.com

41. ObjectInputStream problem    forums.oracle.com

42. Reading file Using ObjectInputStream.....    forums.oracle.com

43. Java 1, ObjectInputStream, '.dat' files and compatability.    forums.oracle.com

I have taken over software development of a product from my client's previous programmer. I have been quite shocked to discover that the program is written in Java 1 even though it has been developed over the last year. Naturally I am trying to update the program to update the program, sort out the tangled code, fix bugs and continue development. ...

44. Using ObjectInputStream over the internet    forums.oracle.com

public void run() { response = new Response(null); try{ // Connect to Server Client host = (Client)ReferenceData.CURRENT_HOST; Socket socket = new Socket(host.getHost(),host.getPort()); //Send Request outStream = new ObjectOutputStream(socket.getOutputStream()); outStream.writeObject(request); outStream.flush(); //Get Response if (responseSize > 0){ requestProgressMonitor = new RequestProgressMonitor(socket.getInputStream(), responseSize); } else{ requestProgressMonitor = new RequestProgressMonitor(socket.getInputStream()); requestProgressMonitor.setTimeOut(request.getTimeOutPeriod()); try{ //inStream = new ObjectInputStream(socket.getInputStream()); inStream = new ObjectInputStream(requestProgressMonitor); response = (Response)inStream.readObject(); } ...

46. problem to calling readObject(java.io.ObjectInputStream) using reflection    forums.oracle.com

private void readObject(java.io.ObjectInputStream inStream) throws IOException, ClassNotFoundException { int version = 0; BufferedInputStream bis = new BufferedInputStream(inStream); bis.mark(256); DataInputStream dis = new DataInputStream(bis); try { version = dis.readInt(); Debug.println(Debug.INFO, _TAG, "Loading version=" + version); } catch(Exception e) { dis.reset(); } switch(version) { case 0: case 1: inStream.defaultReadObject(); migrateDefaultUserToEncryptionPassword(); break; case _VERSION: inStream.defaultReadObject(); break; default: throw new IOException("Unknown Version :" + version); ...

47. A problem with ObjectInputStream    forums.oracle.com

try { System.out.println("Connected from: " + soc.getInetAddress()); ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(soc.getOutputStream())); //ObjectInputStream in = new ObjectInputStream( //new BufferedInputStream(soc.getInputStream())); //Here's the problem int i = 1; while(i<100) { Ob obiekt = new Ob(i,"text"); out.writeObject(obiekt); i++; } out.close(); } catch (IOException ex) { ex.printStackTrace(); } } } class Ob implements Serializable { private int number; private String text;

48. ObjectInputStream error    forums.oracle.com

49. ObjectInputStream Not Working Like It Should    forums.oracle.com

50. ObjectInputStream acts strangely    forums.oracle.com

ObjectInputStream obin = new ObjectInputStream(socket.getInputStream()); ObjectOutputStream obout = new ObjectOutputStream(socket.getOutputStream()); You need to reverse the order of those lines in either the server or the client. The moment you create an object input stream it tries to read a stream header from the underlaying stream. This means that both the server and the client stay wait for the other one to ...

51. ObjectInputStream Question.    forums.oracle.com

I'm having trouble reading an object from ObjectInputStream. I've sucessfully written mixed data to file. An integer, a double, and an Object. The Object is simply a String, I choose to write it as an object because it seemed like the most logical way to write it, .writeChars isn't an option, as there is no .readChars, or a way to read ...

52. trouble with objectInputStream    forums.oracle.com

ok, i need to change that so i can read more than one obj into the file... how could i do that? You're not reading an object into the file, you're reading an object from the file (or out of the file, if you prefer). So assuming you've an unknown number of objects serialized (written) to that file you could do ...

53. reading from objectinputStream twice    forums.oracle.com

but when i loop through arrayList of objectInputstream it only reads once then stops... Example off adding the stream to list userData nameCheck = new UserData(); ObjectInputStream ois = new ObjectInputStream(socket.getobjectInputStream) //socket is passed through class constructor, this is a inner class with thread implemented listofStream.add(ois); //adding to the list of objectinputstream nameCheck = (UserData) = ois.readObject();