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
39 changes: 27 additions & 12 deletions task01/src/com/example/task01/Task01Main.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
package com.example.task01;

import java.io.File;
import java.io.IOException;
import java.io.*;
import java.nio.channels.Pipe;

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

/*
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";
public static String extractSoundName(File file) throws IOException, InterruptedException
{
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("ffprobe", "-v", "error", "-of", "flat", "-show_format", file.getName());
processBuilder.directory(file.getParentFile());


Process process = processBuilder.start();
process.waitFor();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
while (reader.ready()) {
String line = reader.readLine();
if (line.contains("format.tags.title")) {
line = line.split("=")[1].replace("\"", "");
return line;
}
System.out.println(line);
}

}
return "Not found";
}
}
30 changes: 19 additions & 11 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.nio.file.Files;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

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

/*
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
public static List<Path> listFiles(Path rootDir) throws IOException, InterruptedException
{
List<Path> output = new ArrayList<>();

return null;
try(Stream<Path> stream = Files.walk(rootDir))
{
stream.forEach(p -> {
if (!p.toFile().isDirectory())
output.add(p);
});
}
return output;
}
}
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
21 changes: 10 additions & 11 deletions task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.*;

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

/*
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;
public static SampleData deserialize(InputStream inputStream) throws IOException, ClassNotFoundException
{
ObjectInputStream stream = new ObjectInputStream(inputStream);
SampleData output = (SampleData)stream.readObject();
return output;
}
}