Code example for ObjectOutputStream

Methods: closeflushwriteObject

0
		ObjectOutputStream oos = null;
		Response res = null;
			try { 
				s = new Socket("127.0.0.1",12345);
				//ÏÈ°ÑÊý¾Ý·¢¹ýÈ¥£¬ÇëÇó·þÎñÆ÷ 
				oos = new ObjectOutputStream(s.getOutputStream());
				oos.writeObject(req);
				oos.flush();
				 
				//·þÎñÆ÷·¢»ØÏûÏ¢ 
				ois = new ObjectInputStream(s.getInputStream());
				res = (Response) ois.readObject();
			} catch (IOException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} 
			finally{ 
			if (ois != null) {
				try { 
					ois.close();
				} catch (IOException e) {
					e.printStackTrace();
				} 
			} 
			if (oos != null) {
				try { 
					oos.close();
				} catch (IOException e) {
					e.printStackTrace();
				} 
			} 
			} 
Connect your IDE to all the code out there  Get Codota for Java