Code example for ObjectOutputStream

Methods: flush, writeUTF

0
			//System.out.println("Please enter your Username:"); 
			connectToServer = new Socket("localhost",2345);
			System.out.println("hello1!!");
			//inMessageStream = new ObjectInputStream(connectToServer.getInputStream()); 
			System.out.println("hello2!!");
			outMessageStream = new ObjectOutputStream(connectToServer.getOutputStream());
			System.out.println("hello3!!");
			 
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Please enter your Username:");
			String outStr =buf.readLine();
			outMessageStream.writeUTF(outStr);
			outMessageStream.flush();
			 
		}catch(Exception ex){
			ex.printStackTrace();
		} 
		 
	} 
	 
	public static void main(String args[]){