Clean up core-java-8 samples

This commit is contained in:
David Morley
2016-04-21 05:19:51 -05:00
parent fa23486f9a
commit 8cbf2e3b88
24 changed files with 50 additions and 299 deletions

View File

@@ -21,20 +21,20 @@ public class CustomRecursiveAction extends RecursiveAction {
@Override
protected void compute() {
if(workLoad.length() > THRESHOLD) {
if (workLoad.length() > THRESHOLD) {
ForkJoinTask.invokeAll(createSubtasks());
} else {
processing(workLoad);
processing(workLoad);
}
}
private Collection<CustomRecursiveAction> createSubtasks() {
List<CustomRecursiveAction> subtasks =
new ArrayList<>();
new ArrayList<>();
String partOne = workLoad.substring(0, workLoad.length()/2);
String partTwo = workLoad.substring(workLoad.length()/2, workLoad.length());
String partOne = workLoad.substring(0, workLoad.length() / 2);
String partTwo = workLoad.substring(workLoad.length() / 2, workLoad.length());
subtasks.add(new CustomRecursiveAction(partOne));
subtasks.add(new CustomRecursiveAction(partTwo));

View File

@@ -23,7 +23,7 @@ public class CustomRecursiveTask extends RecursiveTask<Integer> {
if (arr.length > THRESHOLD) {
return ForkJoinTask.invokeAll(createSubtasks())
return ForkJoinTask.invokeAll(createSubtasks())
.stream()
.mapToInt(ForkJoinTask::join)
.sum();

View File

@@ -13,7 +13,7 @@ public class UnzipFile {
final byte[] buffer = new byte[1024];
final ZipInputStream zis = new ZipInputStream(new FileInputStream(fileZip));
ZipEntry zipEntry = zis.getNextEntry();
while(zipEntry != null){
while (zipEntry != null) {
final String fileName = zipEntry.getName();
final File newFile = new File("src/main/resources/unzipTest/" + fileName);
final FileOutputStream fos = new FileOutputStream(newFile);

View File

@@ -18,7 +18,7 @@ public class ZipFile {
zipOut.putNextEntry(zipEntry);
final byte[] bytes = new byte[1024];
int length;
while((length = fis.read(bytes)) >= 0) {
while ((length = fis.read(bytes)) >= 0) {
zipOut.write(bytes, 0, length);
}
zipOut.close();

View File

@@ -22,7 +22,7 @@ public class ZipMultipleFiles {
final byte[] bytes = new byte[1024];
int length;
while((length = fis.read(bytes)) >= 0) {
while ((length = fis.read(bytes)) >= 0) {
zipOut.write(bytes, 0, length);
}
fis.close();