annotate src/goodjava/io/DataInputStream.java @ 1555:1b397a949791

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 06 Oct 2020 20:53:43 -0600
parents aaac1d29edea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1492
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.io;
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 import java.io.InputStream;
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 import java.io.IOException;
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 import java.nio.charset.StandardCharsets;
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 public class DataInputStream extends java.io.DataInputStream {
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 public DataInputStream(InputStream in) {
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 super(in);
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 }
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 public String readString() throws IOException {
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 int len = readInt();
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 byte[] a = new byte[len];
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 readFully(a);
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 return new String(a,StandardCharsets.UTF_8);
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 }
aaac1d29edea better io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 }