Events handling

This commit is contained in:
JW
2023-08-16 17:36:40 +02:00
parent 59befcd6f9
commit 4b9e531c95
121 changed files with 4368 additions and 613 deletions

View File

@@ -0,0 +1,38 @@
package io.github.jwdeveloper.tiktok;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
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.Stream;
public class FilesUtility
{
public static List<Path> getFiles(String input) {
Path path = Paths.get(input);
try (Stream<Path> paths = Files.list(path)) {
return paths.filter(Files::isRegularFile).toList();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void saveFile(String path, String content)
{
Path filePath = Paths.get(path);
try {
// Write the content to the file
Files.write(filePath, content.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
}
}