objectinputstream

How can I get an ObjectInputStream that supports mark/reset?

…衆ロ難τιáo~ 提交于 2019-12-13 21:35:24
问题 I'm trying to get an ObjectInputStream that will allow me to read data from it and, if it's not of the right type, put the data back onto the stream (using mark and reset ) for some other code to deal with. I've tried wrapping the InputStream retrieved from the Socket ( s in the following example) in a BufferedInputStream before wrapping it in an ObjectInputStream as I believed to be the solution, however when calling ois.markSupported() false is still returned. Below is that attempt: ois =

getInputStream blocks?

自古美人都是妖i 提交于 2019-12-12 21:39:22
问题 Using Input/Output stream to pass objects between my client and server. I can both send and receive objects with my server, and and now i want the same for the client which as of now only can send. So i gave my client an ObjectInputStream. However, when i initilazie it, it blocks! Been searching around and found answers but no solution. Please help! public GameConnection(String strPort, TextArea chat) { this.port = Integer.parseInt(strPort); System.out.println("GameConnection::Constructor():

ObjectInputStream constructor hangs program

我的未来我决定 提交于 2019-12-12 06:45:44
问题 I have tried every solution I can find to this problem. server = new ServerSocket(9421); client = new Socket("localhost", 9421); out = new ObjectOutputStream(client.getOutputStream()); out.flush(); System.out.println("Starting input streams"); in = new ObjectInputStream(client.getInputStream()); System.out.println("input streams are now running"); Everything tells me to declare the objectInputStream before the ObjectInputStream. Other places tell me to flush the Object output stream. This

Client/Server socket. Doesn't read or write

こ雲淡風輕ζ 提交于 2019-12-12 06:29:31
问题 First of all here are a my compilable projects. IDE = Netbeans I have serversocket in one project and client socket in second project. ServerSocket Project's code Fragment: showStatus(String status); is method which appends text to statusWindow (JTextArea); Socket gameClientSocket,ObjectOutputStream gameoos and ObjectInputStream gameois is declared outside code fragment Code: private void configureSockets() { try{ properties.showStatus("GAME_THREAD-waiting someone to accept");

ObjectInputStream

大兔子大兔子 提交于 2019-12-12 03:57:36
问题 I'm looking for how to use ObjectInputStream for a university project. I found a lot of things but I don't know why I can't succeed with it. Worst, I have more and more warnings. Here are my three classes: public class Contact implements Comparable<Contact> { private String nom; private String prenom; private int numTel; private static int nbContacts; private int numContact; public Contact(String nom, int tel) //Constructeur nom et numero { System.out.println(this.numTel); this.numTel = tel;

How to send java object throw socket

拟墨画扇 提交于 2019-12-12 02:40:55
问题 i'm try to create a simple client/server java application; I have to send a java object throw a socket ... this is the code: client: package performancethinclient; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.Socket; public class PerformanceThinClient { public static void main(String[] args) { startClient("localhost"); } static void startClient(String HOST) { try { Socket clientSocket = new Socket(HOST, 50000); // Create the

Android: ObjectInputSteam.readFully() gets Stuck

我的梦境 提交于 2019-12-12 02:37:02
问题 Situation : I send a boolean variable via ObjectOutputStream from a client to a server. Thereafter, I immediately send a string data via writeChars() function. The server receives the boolean via readBoolean() and spawns a thread accordingly. It reads the string using readFully(bytes[]) . Problem : Server hangs at the line ObjectInputStream.readFully(bytes[]) . Should I just increase the byte size, or is the whole approach wrong ? 回答1: If this is a String and you are using ObjectOutputStream

Java: client-sever app.- WHILE on ObjectInputStream read thread

若如初见. 提交于 2019-12-12 02:08:34
问题 This must be very easy but I am obviously missing some basic understanding. I have simple client server application server: public class GameServer{ private Socket clientSocket; private ServerSocket serverSocket; private ArrayList<ObjectOutputStream> oosPlayers=new ArrayList<ObjectOutputStream>(); public static void main(String args[]){ GameServer server = new GameServer(); server.startGame(); } public void startGame(){ try{ serverSocket = new ServerSocket(10008); System.out.println("Server

Writing objects to file while appending [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-11 19:42:51
问题 This question already has answers here : Write and read multiple objects to file (3 answers) Closed 2 years ago . I have created a program which registers members for a library system. To store the data i have used text files and to read/write i implemented serialization. My problem is when i register one member and try to register another member, the second member records won't get saved. To append writing to the file i used the keyword "true" as well. Here is what i have done: //Am writing

Having Trouble with ObjectInputStream/OutputStream

两盒软妹~` 提交于 2019-12-11 18:15:35
问题 I am having trouble with my programs ability to save my Maps to a file. Here are my two methods for writing and reading my maps and arraylist. Here is my read method: private void getData() throws IOException, ClassNotFoundException { File f_Instructors = new File(PSLTrackerInfo.file + "instructors.brent"); File f_Students = new File(PSLTrackerInfo.file + "students.brent"); File f_Times = new File(PSLTrackerInfo.file + "times.brent"); if (f_Instructors.exists()) { try (ObjectInputStream in =