一,IO流-数据流
二,数据输出流
三,案例
package BigDecimal;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
public class DATaOutputStreamss {
public static void main(String[] args) {
try ( //1,创建一个数据输出流包装低级的字节输出流
DataOutputStream ds =
new DataOutputStream
(new FileOutputStream("untitled\\src\\BigDecimal\\Duxiaonanj.txt"));
){
ds.write(5);
ds.writeDouble(99.5);
ds.writeBoolean(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
四,数据输入流
五,案例
package BigDecimal;
import java.io.DataInputStream;
import java.io.FileInputStream;
public class DATaInputStreamss {
public static void main(String[] args) {
try( DataInputStream ds =new DataInputStream(new FileInputStream("C:\\untitled1\\untitled\\src\\BigDecimal\\Duxiaonanj.txt"))
;){
int i =ds.readInt();
System.out.println(i);
double d =ds.readDouble();
System.out.println(d);
} catch (Exception e) {
e.printStackTrace();
}
}
}