Created
March 17, 2012 00:55
-
-
Save froop/2053985 to your computer and use it in GitHub Desktop.
[Java] サイズを指定してダミーファイルを作成
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
http://stackoverflow.com/questions/245251/create-file-with-given-size-in-java