Skip to content

Test1#9

Open
ASGusev wants to merge 3 commits intomasterfrom
md5
Open

Test1#9
ASGusev wants to merge 3 commits intomasterfrom
md5

Conversation

@ASGusev
Copy link
Owner

@ASGusev ASGusev commented Mar 30, 2017

No description provided.

}

private static void digestFile(MessageDigest digest, Path file) throws IOException {
FileInputStream fin = new FileInputStream(file.toString());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а что, закрывать потоки не надо уже?

digestFile(messageDigest, path);
}
} catch (IOException e) {
Error e1 = new Error();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error не стоит кидать самому, это исключения, которые возникают, когда заканчивается оперативная память или что-то равноценно ужасное, на что мы не можем никак повлиять. то, что на диске файл не нашёлся, в эту категорию явно не попадает

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вполне можно было обойтись обычным циклом по Files.walk(filePath) и не париться с исключениями в внутри лямбды


private static void digestFile(MessageDigest digest, Path file) throws IOException {
FileInputStream fin = new FileInputStream(file.toString());
boolean read = false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

булевы переменные обычно называют, начиная с is

digestFile(digest, curPath);
} else {
int lastNameIndex = curPath.getNameCount() - 1;
digest.update(curPath.getName(lastNameIndex).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

имя посчитали, а содержимое директории?

protected void compute() {
try {
if (Files.isDirectory(path)) {
int lastNameIndex = path.getNameCount() - 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эти две строчки вполне можно было не раскопировать и выделить в отдельный метод


public class Main {
public static void main(String[] args) {
switch (args[0]) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошо бы проверить, что аргумент есть вообще

import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

public class Main {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

по-хорошему доки нужно писать ко всему публичному

case "multithread": {
System.out.println("Calculating MD5 hash for " + args[1] + "...");
try {
System.out.println(new BigInteger(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а время сравнить?

@jzuken
Copy link

jzuken commented Apr 8, 2017

5 баллов

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants