From 6920f37f36efb84e798982d540d27e36d9cc5c17 Mon Sep 17 00:00:00 2001 From: Elaiza-art Date: Mon, 15 Dec 2025 19:10:15 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task01/src/com/example/task01/Task01Main.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/task01/src/com/example/task01/Task01Main.java b/task01/src/com/example/task01/Task01Main.java index 5dfc11b..d6e0fe4 100644 --- a/task01/src/com/example/task01/Task01Main.java +++ b/task01/src/com/example/task01/Task01Main.java @@ -1,20 +1,50 @@ 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 { //здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат // например вот так: - /* System.out.println(extractSoundName(new File("task01/src/main/resources/3727.mp3"))); - */ } public static String extractSoundName(File file) throws IOException, InterruptedException { // your implementation here - return "sound name"; + ProcessBuilder pb = new ProcessBuilder(); + pb.command("C:\\Users\\User\\Downloads\\ffmpeg-8.0.1-essentials_build\\bin\\ffprobe.exe", + "-v", "error", + "-of" ,"flat", + "-show_format", + file.getAbsolutePath()); + pb.directory(new File("E:\\kek\\8-java-io2")); + Process process = pb.start(); + String soundName = null; + try{ BufferedReader bfreader = new BufferedReader( + new InputStreamReader(process.getInputStream())); + + String line; + + while ((line = bfreader.readLine()) != null){ + if (line.startsWith("format.tags.title=")) { + soundName = line.substring("format.tags.title=".length()); + if(soundName.startsWith("\"") && soundName.endsWith("\"")){ + soundName = soundName.substring(1, soundName.length()-1); + } + break; + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } + int exValue = process.waitFor(); + if(exValue != 0){ + throw new RuntimeException("ffprobe завершился с ошибкой: " + exValue); + } + return soundName != null ? soundName : "Unknown"; } } From c8f547130d01f3094a8f2a90c6b02ce6d888c25f Mon Sep 17 00:00:00 2001 From: Elaiza-art Date: Mon, 15 Dec 2025 19:47:52 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task02/src/com/example/task02/Task02Main.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/task02/src/com/example/task02/Task02Main.java b/task02/src/com/example/task02/Task02Main.java index 750f7ba..2569fd3 100644 --- a/task02/src/com/example/task02/Task02Main.java +++ b/task02/src/com/example/task02/Task02Main.java @@ -1,7 +1,10 @@ package com.example.task02; +import java.io.File; 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 { @@ -9,15 +12,27 @@ public static void main(String[] args) throws IOException, InterruptedException //здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат // например вот так: - /* System.out.println(listFiles(Paths.get("task02/src/main/resources/"))); - */ } + public static List listFiles(Path rootDir) { + List result = new ArrayList<>(); + collectFiles(new File(rootDir.toString()), result); + return result; + } - public static List listFiles(Path rootDir) throws IOException, InterruptedException { - // your implementation here - - return null; + private static void collectFiles(File dir, List result) { + if (dir.isDirectory()) { + File[] files = dir.listFiles(); // может вернуть null + if (files != null) { + for (File file : files) { + if (file.isFile()) { + result.add(file.toPath()); + } else if (file.isDirectory()) { + collectFiles(file, result); + } + } + } + } } } From ed7cea8ddd24c693bf7c66684a57b83e94adaadd Mon Sep 17 00:00:00 2001 From: Elaiza-art Date: Mon, 15 Dec 2025 20:08:42 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task03/src/com/example/task03/SampleData.java | 3 ++- task03/src/com/example/task03/Task03Main.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/task03/src/com/example/task03/SampleData.java b/task03/src/com/example/task03/SampleData.java index 0654af5..70bbc0b 100644 --- a/task03/src/com/example/task03/SampleData.java +++ b/task03/src/com/example/task03/SampleData.java @@ -1,9 +1,10 @@ package com.example.task03; +import java.io.Serializable; import java.util.Date; import java.util.Objects; -public class SampleData { +public class SampleData implements Serializable { static final long serialVersionUID = 132706691457162967L; String name; diff --git a/task03/src/com/example/task03/Task03Main.java b/task03/src/com/example/task03/Task03Main.java index 740fff1..7ea7cf8 100644 --- a/task03/src/com/example/task03/Task03Main.java +++ b/task03/src/com/example/task03/Task03Main.java @@ -1,21 +1,24 @@ package com.example.task03; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; public class Task03Main { public static void main(String[] args) throws IOException, ClassNotFoundException { //здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат // например вот так: - /* System.out.println(deserialize(new FileInputStream("task03/src/main/resources/example1.bin"))); - */ } public static SampleData deserialize(InputStream inputStream) throws IOException, ClassNotFoundException { // your implementation here - return null; + try { + ObjectInputStream obj = new ObjectInputStream(inputStream); + Object read = obj.readObject(); + return (SampleData) read; + } catch (IOException e) { + throw new RuntimeException(e); + } } }