FileInputStream fileIn; FileOutputStream fileOut; File file=new File("D:/StreamContent.java");//任意文件路径 byte[] c=new byte[2]; c[0]=0x0d; c[1]=0x0a;//用于输入换行符的字节码 String t=new String(c);//将该字节码转化为字符串类型 String s="shskhdgkhskhgk;hdkshkg,"; s+=t+"sdfsdf"; buf=s.getBytes();//转换为Bit流 fileIn=new FileInputStream(file); count=buf.length; fileOut= new FileOutputStream("D:/FileOutputStreamTest.txt");//要写入的文件路径 fileOut.write(buf,0,count); count=fileIn.read(buf); fileOut.write(buf,0,count);
时间: 2024-11-01 18:19:00