1、DataInputStream和DataOutputStream都是Java中输入输出流的装饰类,用起来很方便。
package another;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class TestDataStream {
public static void main(String[] args) throws Exception {
//新建
FileOutputStream fos=new FileOutputStream("E://dahjkdhajkdata.txt");
//读出
BufferedOutputStream bos=new BufferedOutputStream(fos);
//输出流
DataOutputStream dos=new DataOutputStream(bos);
//
FileInputStream fis=new FileInputStream("E://dahjkdhajkdata.txt");
BufferedInputStream bis=new BufferedInputStream(fis);
DataInputStream dis=new DataInputStream(bis);
String str="你好hi";
dos.writeUTF(str);