Code example for ObjectOutputStream

Methods: close, flush, writeUTF

0
	    	try{ 
	    		 
	    		if(out != null)
	    		{ 
	    			Log.v("connection","password="+data);
	    			out.writeUTF(data);
	    			out.flush();
	    			 
	    		} 
	    	}catch (IOException e){
	    		disconnect(); 
	    		e.printStackTrace();
	    	} 
	    } 
	     
	    public String receive(){
	    	 
	    	try{ 
	    		String data=in.readUTF();
	    		Log.v("connection","receiving"+data);
	    		return data;
	    	  		 
	    	}catch (IOException e){
	    		e.printStackTrace();
	    		return null; 
	    	} 
	    	 
	    } 
	     
	    public boolean connectionstatus(){ 
	    	if(client != null){
	    		return client.isConnected()&&connectionstatus;
	    	} 
	    	return false; 
	    } 
	     
	    public void disconnect(){ 
	    	connectionstatus=false;
	    		try { 
	    			if(in != null)
	    				in.close();				
	    			if(out != null)
	    				out.close();
	    			if(client!=null)
	    				client.close();
	    			// TODO set send to pc key to not connected state 
	    			Log.v("dictation","Disconnected");
				} catch (IOException e) {