首页 > 移动平台 > 详细

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

时间:2014-12-21 15:12:10      阅读:1617      评论:0      收藏:0      [点我收藏+]
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); 

  

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

原文:http://www.cnblogs.com/li-fei/p/4176587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!