public final void write(byte[] w, int off, int len)throws IOException
将指定字节数组中从偏移量 off 开始的 len 个字节写入此字节数组输出流。
2Public final int write(byte [] b)throws IOException
将指定的字节写入此字节数组输出流。
3
public final void writeBooolean()throws IOException,
public final void writeByte()throws IOException,
public final void writeShort()throws IOException,
public final void writeInt()throws IOException
这些方法将指定的基本数据类型以字节的方式写入到输出流。
4Public void flush()throws IOException
刷新此输出流并强制写出所有缓冲的输出字节。
5public final void writeBytes(String s) throws IOException
将字符串以字节序列写入到底层的输出流,字符串中每个字符都按顺序写入,并丢弃其高八位。
实例
下面的例子演示了DataInputStream和DataOutputStream的使用,该例从文本文件test.txt中读取5行,并转换成大写字母,最后保存在另一个文件test1.txt中。
test.tx 文件内容如下:
runoob1
runoob2
runoob3
runoob4
runoob5
实例
import java.io.*;
public class Test{
public static void main(String args[])throws IOException{
DataInputStream in = new DataInputStream(new FileInputStream("test.txt"));
DataOutputStream out = new DataOutputStream(new FileOutputStream("test