DataInputStream与DataOutputStream
public class DataStream {
public static void main(String[] args) throws IOException {
writeData();
readData();
}
private static void readData() throws IOException {
DataInputStream dis = new DataInputStream(new FileInputStream("abc.txt"));
String str = dis.readUTF();
System.out.println(str);
dis.close();
}
private static void writeData() throws IOException {
DataOutputStream dos = new DataOutputStream(new FileOutputStream("abc.txt"));
dos.writeUTF("你好");
dos.close();
}
}