package net.thepinguin.jp.json;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

import com.google.gson.Gson;

import net.thepinguin.jp.json.jpacker.Root;

public class ParseJP {

	public static Root parseFromFile(String filename) throws IOException {
		// read from file
		StringBuilder sb = new StringBuilder();
		List<String> ss = Files.readAllLines(Paths.get(filename), Charset.defaultCharset());
		for(String s : ss){
			sb.append(s);
		}
		return Root.factory(sb.toString());
	}
	
	public String toJson() {
		return (new Gson()).toJson(this);
	}

	public static Root parseFromString(String rawJson) {
		return Root.factory(rawJson);
	}

}

@@ -41,27 +41,31 @@
 java.io.
-IOException
+FileInputStream
 ;%0Aimport
@@ -74,109 +74,62 @@
 ava.
-n
 io.
-charset.Charset;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0Aimport java.util.List
+IOException;%0Aimport org.apache.commons.io.IOUtils
 ;%0A
-%0A
 impo
@@ -149,25 +149,24 @@
 .gson.Gson;%0A
-%0A
 import net.t
@@ -362,134 +362,183 @@
 ;%0A%09%09
-List%3CString%3E ss = Files.readAllLines(Paths.get(filename), Charset.defaultCharset());%0A%09%09for(String s : ss)%7B%0A%09%09%09sb.append(s);%0A%09%09
+FileInputStream inputStream = new FileInputStream(filename);%0A%09    try %7B%0A%09        sb.append(IOUtils.toString(inputStream));%0A%09    %7D finally %7B%0A%09        inputStream.close();%0A%09    
 %7D%0A%09%09

Fix Java6 (rm java.nio)