码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-12-21 15:13:47      阅读:229      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!