Mercurial Hosting > luan
diff src/goodjava/io/DataInputStream.java @ 1492:aaac1d29edea
better io
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 02 May 2020 22:25:56 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/goodjava/io/DataInputStream.java Sat May 02 22:25:56 2020 -0600 @@ -0,0 +1,20 @@ +package goodjava.io; + +import java.io.InputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + + +public class DataInputStream extends java.io.DataInputStream { + + public DataInputStream(InputStream in) { + super(in); + } + + public String readString() throws IOException { + int len = readInt(); + byte[] a = new byte[len]; + readFully(a); + return new String(a,StandardCharsets.UTF_8); + } +}