Code example for SocketChannel

Methods: write

0
			// TODO Auto-generated catch block 
			e.printStackTrace(); 
		} 
		buf.flip(); 
		try { 
			sc.write(buf); 
		} catch (IOException e) { 
			// TODO Auto-generated catch block 
			e.printStackTrace(); 
		} 
	} 
 
	private static void receiveResponse(SocketChannel sc) { 
		//ByteBuffer buf = ByteBuffer.allocateDirect(1024); 
		ByteBuffer buf = ByteBuffer.allocate(1024); 
 
		@SuppressWarnings("unused") 
		int count = 0; 
		try { 
			while ((count = sc.read(buf)) > 0) { 
				System.out.println(new String(buf.array(), "UTF-8"));