adds File Helper, project files and gitignore

This commit is contained in:
2024-04-20 18:43:55 +02:00
parent 60a6389de1
commit f98a13c3d1
9 changed files with 192 additions and 0 deletions

16
java_src/FileHelper.java Normal file
View File

@@ -0,0 +1,16 @@
package java_src;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class FileHelper {
public static String readJson(Path path) throws IOException {
StringBuilder jsonString = new StringBuilder();
for (String line : Files.readAllLines(path)) {
jsonString.append(line);
}
return jsonString.toString();
}
}

17
java_src/TryOut.java Normal file
View File

@@ -0,0 +1,17 @@
package java_src;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
public class TryOut {
public static void main(String[] args) {
try {
Path path = Paths.get("/home/jan/git-projekte/howtodata/JSON/alice.json");
System.out.println(FileHelper.readJson(path));
} catch (IOException e) {
System.err.println(e.toString());
}
}
}