feature/BAEL-6712-split large file (#15262)
* feature/BAEL-6712-split lareg file * feature/BAEL-6712-split lareg file * bael-6712 review comment fix --------- Co-authored-by: Sachin kumar <sachin.n.kumar@oracle.com>
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
package com.baeldung.splitlargefile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public class SplitLargeFileUnitTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void prepareData() throws IOException {
|
||||
Files.createDirectories(Paths.get("target/split"));
|
||||
}
|
||||
|
||||
private String splitedFileDirPath() throws Exception {
|
||||
return Paths.get("target").toString() + "/split";
|
||||
}
|
||||
|
||||
private Path largeFilePath() throws Exception {
|
||||
return Paths.get(this.getClass().getClassLoader().getResource("large-file.txt").toURI());
|
||||
}
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void givenLargeFile_whenSplitLargeFile_thenSplitBySize() throws Exception {
|
||||
File input = largeFilePath().toFile();
|
||||
SplitLargeFile slf = new SplitLargeFile();
|
||||
slf.splitByFileSize(input, 1024_000, splitedFileDirPath());
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void givenLargeFile_whenSplitLargeFile_thenSplitByNumberOfFiles() throws Exception {
|
||||
File input = largeFilePath().toFile();
|
||||
SplitLargeFile slf = new SplitLargeFile();
|
||||
slf.splitByNumberOfFiles(input, 3, splitedFileDirPath());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user