Mercurial > hg > Members > you > TreeVNC
view src/treeVnc/DataInputStream2.java @ 53:923513c47b8f
add files
author | one |
---|---|
date | Tue, 22 May 2012 17:32:23 +0900 |
parents | |
children |
line wrap: on
line source
package treeVnc; import java.io.IOException; import java.net.DatagramSocket; import java.nio.ByteBuffer; import java.nio.channels.DatagramChannel; public class DataInputStream2 extends DataInputStream1 { private DatagramChannel datagramChannel; public DataInputStream2(DatagramSocket broadcast) { super(); datagramChannel = broadcast.getChannel(); } @Override public void readFully(byte[] b, int off, int len) throws IOException { long count = 0; ByteBuffer[] bf = {ByteBuffer.wrap(b)}; while(count < len) { long i = datagramChannel.read(bf, off, len); if(i==-1) { throw new IOException(); } count += i; } buf = bf[0]; } }