11package alpine .json ;
22
3- import java .io .IOException ;
3+ import java .io .* ;
44import java .nio .file .Files ;
55import java .nio .file .Path ;
66import java .util .Map ;
@@ -73,6 +73,10 @@ public static Element read(Path path) throws ParsingException {
7373 }
7474 }
7575
76+ public static Element read (File file ) throws ParsingException {
77+ return read (file .toPath ());
78+ }
79+
7680 public static String write (Element element , Formatting formatting ) {
7781 return WRITER .write (element , formatting );
7882 }
@@ -85,6 +89,10 @@ public static void write(Path path, Element element, Formatting formatting) {
8589 }
8690 }
8791
92+ public static void write (File file , Element element , Formatting formatting ) {
93+ write (file .toPath (), element , formatting );
94+ }
95+
8896 static boolean isControl (char character ) {
8997 return character <= 0x1F ;
9098 }
@@ -99,13 +107,13 @@ static boolean isWhitespace(char character) {
99107 public record Formatting (String indentation , String newLine , String comma , String colon ) {
100108 public static final Formatting COMPACT = new Formatting (
101109 "" ,
102- String . valueOf ( LINE_FEED ),
110+ System . lineSeparator ( ),
103111 String .valueOf (COMMA ),
104112 String .valueOf (COLON ));
105113
106114 public static final Formatting PRETTY = new Formatting (
107115 String .valueOf (SPACE ).repeat (4 ),
108- String . valueOf ( LINE_FEED ),
116+ System . lineSeparator ( ),
109117 COMPACT .comma + SPACE ,
110118 COMPACT .colon + SPACE );
111119 }
0 commit comments