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
38 changes: 31 additions & 7 deletions task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
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")));
*/
System.out.println("1 трек — " + extractSoundName(new File("task01/src/main/resources/3724.mp3")));
System.out.println("2 трек — " + extractSoundName(new File("task01/src/main/resources/3726.mp3")));
System.out.println("3 трек — " + 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 processBuilder = new ProcessBuilder(
"ffprobe", "-v", "error", "-of", "flat", "-show_format", file.getAbsolutePath()
);

Process process = processBuilder.start();

BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
String title = null;

while ((line = reader.readLine()) != null) {
if (line.contains("format.tags.title")) {
int equalsIndex = line.indexOf('=');
if (equalsIndex != -1) {
title = line.substring(equalsIndex + 1).replaceAll("\"", "");
break;
}
}
}

int exitCode = process.waitFor();
if (exitCode != 0) {
throw new IOException("ffprobe завершился с ошибкой. Код: " + exitCode);
}

return title != null ? title : "название трека не найдено";
}
}
16 changes: 12 additions & 4 deletions task02/src/com/example/task02/Task02Main.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package com.example.task02;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Task02Main {
public static void main(String[] args) throws IOException, InterruptedException {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:

/*
System.out.println(listFiles(Paths.get("task02/src/main/resources/")));
*/


}

public static List<Path> listFiles(Path rootDir) throws IOException, InterruptedException {
// your implementation here
if (!Files.exists(rootDir) || !Files.isDirectory(rootDir)) {
throw new IllegalArgumentException("Указанный путь не является существующей директорией: " + rootDir);
}

return null;
try (Stream<Path> paths = Files.walk(rootDir)) {
return paths.filter(Files::isRegularFile).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
@@ -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;
Expand Down
9 changes: 5 additions & 4 deletions task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

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

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 objectInputStream = new ObjectInputStream(inputStream)) {
return (SampleData) objectInputStream.readObject();
}
}
}