tags:

views:

95

answers:

2

Hi,

I would like to know what is the most efficient way to create a very large dummy File in java. The filesize should be just above 1GB. It will be used to unit test a method which only accepts files <= 1GB.

+2  A: 

Can't you make a mock which returns filesize of > 1GB? File IO doesn't sound very unit-testy to me (although that depends on what your idea of a unit test is).

Skilldrick
I want to test a piece of code which loads a file from disk based on a filename and does some validation checks. So it has to be a real file.
Fortega
+5  A: 

Create a sparse file. That is, open a file, seek to a position above 1GB and write some bytes.

Relevant: Create file with given size in Java

Sjoerd
+1 - pretty interesting
Dave McClelland
That's what I needed. Thanks!
Fortega