From 4a027fab5fa4ec4665ec85f030ed7629ba091d84 Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Fri, 20 Nov 2015 16:09:07 +0100 Subject: [PATCH 1/2] Added setContent method --- src/zutil/io/file/FileUtil.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/zutil/io/file/FileUtil.java b/src/zutil/io/file/FileUtil.java index c732c30..b997c0f 100755 --- a/src/zutil/io/file/FileUtil.java +++ b/src/zutil/io/file/FileUtil.java @@ -147,6 +147,17 @@ public class FileUtil { return data; } + /** + * Replaces the contents of a file with the specified data. + * + * @param file the file to write the data to + * @param data the data to write to the file + */ + public static void setContent(File file, byte[] data) throws IOException{ + OutputStream out = new FileOutputStream(file); + out.write(data); + out.close(); + } /** * Cache for the search functions From 52c6f7e01c962a387a6df397175779cf2aa3a91c Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Fri, 20 Nov 2015 16:51:19 +0100 Subject: [PATCH 2/2] Some bug fixes --- src/zutil/parser/json/JSONObjectInputStream.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/zutil/parser/json/JSONObjectInputStream.java b/src/zutil/parser/json/JSONObjectInputStream.java index b40af53..6114457 100755 --- a/src/zutil/parser/json/JSONObjectInputStream.java +++ b/src/zutil/parser/json/JSONObjectInputStream.java @@ -162,9 +162,11 @@ public class JSONObjectInputStream extends InputStream implements ObjectInput, C Map map = (Map)type.newInstance(); for(Iterator it=json.keyIterator(); it.hasNext();){ String subKey = it.next(); - map.put( - subKey, - readType((genType.length>=2? genType[1] : null), null, subKey, json.get(subKey))); + if(json.get(subKey) != null) { + map.put( + subKey, + readType((genType.length >= 2 ? genType[1] : null), null, subKey, json.get(subKey))); + } } return map; }