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
37 changes: 30 additions & 7 deletions task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
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";
String ffProbePath = "C:\\Users\\User\\Desktop\\ffmpeg-2024-11-28-git-bc991ca048-full_build\\bin\\ffprobe.exe";

ProcessBuilder processBuilder = new ProcessBuilder(ffProbePath, "-v", "error", "-of", "flat", "-show_format", file.getAbsolutePath());
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();

return parseTitle(readProcessOutput(process));
}

private static String readProcessOutput(Process process) throws IOException {
String output = "";
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = reader.readLine()) != null) {
output += line + "\n";
}
}
return output;
}

private static String parseTitle(String output) {
String titlePrefix = "format.tags.title=";
for (String line : output.split("\n")) {
if (line.contains(titlePrefix)) {
return line.substring(line.indexOf(titlePrefix) + titlePrefix.length()).replace("\"", "").trim();
}
}
return "Название не найдено";
}
}
8 changes: 4 additions & 4 deletions task02/src/com/example/task02/Task02Main.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -15,9 +17,7 @@ public static void main(String[] args) throws IOException, InterruptedException

}

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

return null;
public static List<Path> listFiles(Path rootDir) throws IOException {
return Files.walk(rootDir).filter(path -> path.toFile().isFile()).collect(Collectors.toList());
}
}
3 changes: 2 additions & 1 deletion task03/src/com/example/task03/SampleData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

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

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

String name;
Expand Down
10 changes: 8 additions & 2 deletions task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.example.task03;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.nio.file.Files;

public class Task03Main {
public static void main(String[] args) throws IOException, ClassNotFoundException {
Expand All @@ -15,7 +18,10 @@ 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)){
SampleData res = (SampleData) obj.readObject();
return res;
}
}
}