首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

【java】各种对资料,读写的方法及小例子

2012-09-28 
【java】各种对文件,读写的方法及小例子import java.io.* public class Test {/*** @param args the comman

【java】各种对文件,读写的方法及小例子

import java.io.*; public class Test {    /**     * @param args the command line arguments     */    public static void main(String[] args) throws FileNotFoundException, IOException {       FileWriter fw = new FileWriter("test.txt");        fw.write("dddd");//直接这样就行..他会自动转换为其Unicode编码..或者fw.write((int)c);强制转换一下也行        fw.append("wwwwww");        fw.flush();        fw.close();                FileReader fr = new FileReader("test.txt");          int ch = 0;          while((ch = fr.read())!=-1 )          {             System.out.print((char)ch);          }     }}


热点排行