adds File Helper, project files and gitignore
This commit is contained in:
16
java_src/FileHelper.java
Normal file
16
java_src/FileHelper.java
Normal 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
17
java_src/TryOut.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user