Skip to content

Instantly share code, notes, and snippets.

@froop
Created March 17, 2012 00:55
Show Gist options
  • Save froop/2053985 to your computer and use it in GitHub Desktop.
Save froop/2053985 to your computer and use it in GitHub Desktop.
[Java] サイズを指定してダミーファイルを作成
public static void createDummyFile(String name, int length) throws IOException {
RandomAccessFile file = new RandomAccessFile(name, "rw");
file.setLength(length);
file.close();
}
@Test
public void testCreateDummyFile() throws IOException {
File file = new File("work/DummyFile");
file.delete();
createDummyFile(file.getPath(), 100);
assertEquals(100, file.length());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment