public static void createEmptyFile(File file,long length) throws IOException {
  if (file == null || length <= 0) {
    throw new IllegalArgumentException("File instance is null or length is not positive");
  }
  try (FileOutputStream fOut=new FileOutputStream(file);FileChannel fChannel=fOut.getChannel()){
    fChannel.write(ByteBuffer.allocate(1),length - 1);
  }
 }

public static void createEmptyFile ( File file , long length ) throws IOException { if ( file == null || length <= 0 ) { throw new IllegalArgumentException ( "File instance is null or length is not positive" ) ; } try ( FileOutputStream fOut = new FileOutputStream ( file ) ; FileChannel fChannel = fOut . getChannel ( ) ) { fChannel . write ( ByteBuffer . allocate ( 1 ) , length - 1 ) ; } }
creates file with specified length
