diff src/goodjava/io/DataOutputStream.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/DataOutputStream.java	Sat May 02 22:25:56 2020 -0600
@@ -0,0 +1,19 @@
+package goodjava.io;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+
+public class DataOutputStream extends java.io.DataOutputStream {
+
+	public DataOutputStream(OutputStream out) {
+		super(out);
+	}
+
+	public void writeString(String s) throws IOException {
+		byte[] a = s.getBytes(StandardCharsets.UTF_8);
+		writeInt(a.length);
+		write(a);
+	}
+}