Mercurial > hg > Members > you > TreeVNC
comparison src/treeVnc/DataInputStream2.java @ 53:923513c47b8f
add files
author | one |
---|---|
date | Tue, 22 May 2012 17:32:23 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
52:d8f8123dcefc | 53:923513c47b8f |
---|---|
1 package treeVnc; | |
2 | |
3 import java.io.IOException; | |
4 import java.net.DatagramSocket; | |
5 import java.nio.ByteBuffer; | |
6 import java.nio.channels.DatagramChannel; | |
7 | |
8 public class DataInputStream2 extends DataInputStream1 { | |
9 private DatagramChannel datagramChannel; | |
10 | |
11 public DataInputStream2(DatagramSocket broadcast) { | |
12 super(); | |
13 datagramChannel = broadcast.getChannel(); | |
14 } | |
15 | |
16 @Override | |
17 public void readFully(byte[] b, int off, int len) throws IOException { | |
18 long count = 0; | |
19 ByteBuffer[] bf = {ByteBuffer.wrap(b)}; | |
20 while(count < len) { | |
21 long i = datagramChannel.read(bf, off, len); | |
22 if(i==-1) { | |
23 throw new IOException(); | |
24 } | |
25 count += i; | |
26 } | |
27 buf = bf[0]; | |
28 } | |
29 | |
30 } |