posts - 1, comments - 4, trackbacks - 0, articles - 0

          java.io

          Posted on 2006-06-20 13:15 JavaDoIt 閱讀(482) 評(píng)論(4)  編輯  收藏
          public static void Url() throws MalformedURLException{ File file = new File("b.txt"); URL url =null; url = file.toURL(); String dir =file.getPath(); System.out.print(file.getAbsolutePath()); file.renameTo(new File(dir,file.getName())); } public static void cope()throws IOException{ File file = new File("b.txt"); File file2 = new File("c.txt"); if(!file2.exists()){ file2.createNewFile(); } FileInputStream in = new FileInputStream(file); // InputStream in = url.openStream(); FileOutputStream out = new FileOutputStream(file2); byte[] buffer = new byte[4096]; int data; while((data = in.read(buffer))!=-1){ out.write(buffer,0,data); } in.close(); out.close(); } public static void read() throws IOException{ File file = new File("b.txt"); System.out.print("Overwrite existing file " + file.getName() +"? (Y/N): "); System.out.flush(); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String readtowrite = in.readLine(); BufferedWriter ot = new BufferedWriter(new FileWriter("b.txt")); ot.write(readtowrite); ot.close(); } public static void test() throws IOException{ File file = new File("b.txt"); if(!file.exists()){ file.createNewFile(); } File file2 = new File("c.txt"); if(!file2.exists()){ file2.createNewFile(); } FileInputStream in = new FileInputStream(file); // InputStream in = url.openStream(); FileOutputStream out = new FileOutputStream(file2); byte[] buffer = new byte[4096]; int data; while((data = in.read(buffer))!=-1){ out.write(buffer,0,data); } in.close(); out.close(); } public static void compress() throws IOException{ File file = new File("b.txt"); FileInputStream in = new FileInputStream(file); String to =file.getName()+".zip"; GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream("e:/"+to)); byte[] buffer = new byte[4096]; int data; while((data = in.read(buffer))!=-1){ out.write(buffer,0,data); } in.close(); out.close(); }

          Feedback

          # re: java.io  回復(fù)  更多評(píng)論   

          2006-06-20 14:42 by aa
          你寫(xiě)這要哪個(gè)看?
          垃圾拿出來(lái)丟人現(xiàn)眼

          # re: java.io  回復(fù)  更多評(píng)論   

          2006-06-20 14:50 by ChuPaChuPs
          混亂程序大賽么。。。這個(gè)還未夠班口牙。。。

          # re: java.io  回復(fù)  更多評(píng)論   

          2006-06-20 15:20 by dudu
          你的帳戶(hù)被限制!

          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 苏州市| 镇沅| 定州市| 山阴县| 定日县| 宁南县| 扶余县| 长寿区| 辛集市| 临颍县| 弥渡县| 岚皋县| 青龙| 抚顺市| 林州市| 唐河县| 常宁市| 靖西县| 浏阳市| 沂源县| 海城市| 庆阳市| 博罗县| 浮山县| 张掖市| 禹城市| 化德县| 黄平县| 通榆县| 加查县| 奉新县| 吉木萨尔县| 盖州市| 衡南县| 高陵县| 清水河县| 新蔡县| 米林县| 顺平县| 崇明县| 昆山市|