-
Notifications
You must be signed in to change notification settings - Fork 0
/
JunkFile.java
34 lines (28 loc) · 864 Bytes
/
JunkFile.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class JunkFile
{
public static void main (String[] args)
{
try {
final int BYTE_IN_MEGABYTE = 1048576;
int fsize = BYTE_IN_MEGABYTE * 50;
File f = new File("JunkFile.txt");
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
// 1 char = 2 bytes
while (f.length() < fsize)
{
// This array is 50 bytes.
byte[] b = {'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'};
fos.write(b);
System.out.print("\rWrote " + f.length() + " / " + fsize);
}
System.out.println("\n\nFile: " + f.getAbsolutePath());
System.out.println("Size (bytes): " + f.length());
} catch (IOException ex) {
System.out.println(ex);
}
}
}