@Test public void testGetNumberOfChunksRandom() throws IOException { Random rnd = new Random(); for (int i = 0; i < 10; i++) { int genNOC = rnd.nextInt(100) + 1; File randomFile = FileTestUtil.createFileRandomContent(genNOC, parent); int resNOC = FileChunkUtil.getNumberOfChunks(randomFile, TestFileConfiguration.CHUNK_SIZE); assertEquals(genNOC, resNOC); randomFile.deleteOnExit(); } }
public static int getNumberOfChunks(File file, int chunkSize) { if (file == null || !file.exists()) { return 0; } else if (chunkSize <= 0) { return 0; } long fileSize = FileUtil.getFileSize(file); if (fileSize == 0) { return 1; } return (int) Math.ceil((double) fileSize / Math.abs(chunkSize)); }
FileChunkUtil { public static int getNumberOfChunks(File file, int chunkSize) { if (file == null || !file.exists()) { return 0; } else if (chunkSize <= 0) { return 0; } long fileSize = FileUtil.getFileSize(file); if (fileSize == 0) { return 1; } return (int) Math.ceil((double) fileSize / Math.abs(chunkSize)); } }
FileChunkUtil { public static int getNumberOfChunks(File file, int chunkSize) { if (file == null || !file.exists()) { return 0; } else if (chunkSize <= 0) { return 0; } long fileSize = FileUtil.getFileSize(file); if (fileSize == 0) { return 1; } return (int) Math.ceil((double) fileSize / Math.abs(chunkSize)); } private  FileChunkUtil(); }
FileChunkUtil { public static int getNumberOfChunks(File file, int chunkSize) { if (file == null || !file.exists()) { return 0; } else if (chunkSize <= 0) { return 0; } long fileSize = FileUtil.getFileSize(file); if (fileSize == 0) { return 1; } return (int) Math.ceil((double) fileSize / Math.abs(chunkSize)); } private  FileChunkUtil(); static int getNumberOfChunks(File file, int chunkSize); static Chunk getChunk(File file, int chunkSize, int chunkNumber, String chunkId); static void reassembly(List<File> fileParts, File destination); }
FileChunkUtil { public static int getNumberOfChunks(File file, int chunkSize) { if (file == null || !file.exists()) { return 0; } else if (chunkSize <= 0) { return 0; } long fileSize = FileUtil.getFileSize(file); if (fileSize == 0) { return 1; } return (int) Math.ceil((double) fileSize / Math.abs(chunkSize)); } private  FileChunkUtil(); static int getNumberOfChunks(File file, int chunkSize); static Chunk getChunk(File file, int chunkSize, int chunkNumber, String chunkId); static void reassembly(List<File> fileParts, File destination);  }