diff --git a/task01/src/com/example/task01/Task01Main.java b/task01/src/com/example/task01/Task01Main.java index 5dfc11b0..1f95133c 100644 --- a/task01/src/com/example/task01/Task01Main.java +++ b/task01/src/com/example/task01/Task01Main.java @@ -1,7 +1,9 @@ package com.example.task01; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; public class Task01Main { public static void main(String[] args) throws IOException, InterruptedException { @@ -13,8 +15,20 @@ public static void main(String[] args) throws IOException, InterruptedException */ } - public static String extractSoundName(File file) throws IOException, InterruptedException { - // your implementation here - return "sound name"; + + public static String extractSoundName(File file) throws IOException { + ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "ffprobe -v error -of flat -show_format ", file.getAbsolutePath()); + builder.directory(new File("C:\\ffmpeg\\bin")); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(builder.start().getInputStream()))) { + String line; + while ((line = reader.readLine()) != null) { + if (line.contains("title")) { + if (line.contains("title")) { + return line.split("\"")[1]; + } + } + } + return null; + } } } diff --git a/task02/src/com/example/task02/Task02Main.java b/task02/src/com/example/task02/Task02Main.java index 750f7bab..5b5df8b6 100644 --- a/task02/src/com/example/task02/Task02Main.java +++ b/task02/src/com/example/task02/Task02Main.java @@ -1,8 +1,10 @@ package com.example.task02; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.List; +import java.util.stream.Collectors; public class Task02Main { public static void main(String[] args) throws IOException, InterruptedException { @@ -15,9 +17,10 @@ public static void main(String[] args) throws IOException, InterruptedException } - public static List listFiles(Path rootDir) throws IOException, InterruptedException { + public static List listFiles(Path rootDir) throws IOException { // your implementation here - return null; + return Files.walk(rootDir).filter(path -> path.toFile().isFile()).collect(Collectors.toList()); } + } diff --git a/task03/src/com/example/task03/SampleData.java b/task03/src/com/example/task03/SampleData.java index 0654af50..c00f3691 100644 --- a/task03/src/com/example/task03/SampleData.java +++ b/task03/src/com/example/task03/SampleData.java @@ -2,9 +2,10 @@ import java.util.Date; import java.util.Objects; +import java.io.Serializable; -public class SampleData { - static final long serialVersionUID = 132706691457162967L; +public class SampleData implements Serializable { + private static final long serialVersionUID = 132706691457162967L; String name; int value; diff --git a/task03/src/com/example/task03/Task03Main.java b/task03/src/com/example/task03/Task03Main.java index 740fff14..c2d6f61c 100644 --- a/task03/src/com/example/task03/Task03Main.java +++ b/task03/src/com/example/task03/Task03Main.java @@ -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 { @@ -16,6 +17,8 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio public static SampleData deserialize(InputStream inputStream) throws IOException, ClassNotFoundException { // your implementation here - return null; + try (ObjectInputStream obj = new ObjectInputStream(inputStream)) { + return (SampleData) obj.readObject(); + } } }