Android的FileOutputStream中向文本文件中写入换行符

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); 

  

posted @ 2014-12-21 14:40  gin飞飞ing  阅读(1462)  评论(0编辑  收藏  举报