Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.task01;

import java.io.File;
import java.io.IOException;
import java.io.*;

public class Task01Main {
public static void main(String[] args) throws IOException, InterruptedException {
Expand All @@ -14,7 +13,27 @@ public static void main(String[] args) throws IOException, InterruptedException
}

public static String extractSoundName(File file) throws IOException, InterruptedException {
// your implementation here
return "sound name";

String title = null;

ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("ffprobe", "-v", "error", "-of", "flat", "-show_format", file.getName());
processBuilder.directory(file.getParentFile());

Process process = processBuilder.start();

try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("format.tags.title")) {
title = line.split("=")[1].replace("\"", "");
break;
}
}
}

process.waitFor();

return title;
}
}
17 changes: 14 additions & 3 deletions task02/src/com/example/task02/Task02Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.example.task02;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;

public class Task02Main {
Expand All @@ -16,8 +18,17 @@ public static void main(String[] args) throws IOException, InterruptedException
}

public static List<Path> listFiles(Path rootDir) throws IOException, InterruptedException {
// your implementation here

return null;
List<Path> result = new ArrayList<>();

Files.walkFileTree(rootDir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
result.add(file);
return FileVisitResult.CONTINUE;
}
});

return result;
}
}
5 changes: 3 additions & 2 deletions task03/src/com/example/task03/SampleData.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.example.task03;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

public class SampleData {
static final long serialVersionUID = 132706691457162967L;
public class SampleData implements Serializable {
private static final long serialVersionUID = 132706691457162967L;

String name;
int value;
Expand Down
11 changes: 9 additions & 2 deletions task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;

public class Task03Main {
public static void main(String[] args) throws IOException, ClassNotFoundException {
Expand All @@ -15,7 +16,13 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio
}

public static SampleData deserialize(InputStream inputStream) throws IOException, ClassNotFoundException {
// your implementation here
return null;

SampleData deserializedData;

try (ObjectInputStream objectInputStream = new ObjectInputStream(inputStream)) {
deserializedData = (SampleData) objectInputStream.readObject();
}

return deserializedData;
}
}