package code;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import org.json.JSONObject;

public class Helper {

	public static synchronized void scriviFile(JSONObject json, String path) throws IOException {
		BufferedWriter b = new BufferedWriter(new FileWriter(path));
		b.write(json.toString());
		b.close();
	}
	
	public static synchronized String leggiFile(String path) throws IOException {
		String line;
		String answer = "";
		FileReader fileReader = new FileReader(path);
		BufferedReader bufferedReader = new BufferedReader(fileReader);
		while((line = bufferedReader.readLine()) != null) {
			answer += line;
		}
		bufferedReader.close();
		return answer;
	}
	
}