[
https://issues.apache.org/jira/browse/WAGON-482?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Michael Osipov updated WAGON-482:
---------------------------------
Fix Version/s: 3.0.1
> Use sparse files in HugeFileDownloadTest with Java 7
> -----------------------------------------------------
>
> Key: WAGON-482
> URL: https://issues.apache.org/jira/browse/WAGON-482
> Project: Maven Wagon
> Issue Type: Improvement
> Components: wagon-http
> Affects Versions: 2.11
> Reporter: Michael Osipov
> Assignee: Michael Osipov
> Priority: Major
> Fix For: 3.0.1
>
>
> Unfortunately, {{RandomAccessFile}} does not create sparse files on Windows
> with seek/position, it requires a specific flag set with NTFS. Luckily, NIO.2
> supports this. File creation for 4 GiB will be tens of milliseconds. Use this
> snippet as soon as we move to Java 7:
> {code:java}
> Path tempDirectory = Files.createTempDirectory("jetty");
> final ByteBuffer buf = ByteBuffer.allocate(4).putInt(2);
> buf.rewind();
> final OpenOption[] options = { StandardOpenOption.WRITE,
> StandardOpenOption.CREATE_NEW , StandardOpenOption.SPARSE };
> final Path hugeFile = tempDirectory.resolve("hugefile.txt");
> try (final SeekableByteChannel channel = Files.newByteChannel(hugeFile,
> options);) {
> channel.position(HUGE_FILE_SIZE);
> channel.write(buf);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)