Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package json;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import org.json.JSONArray;
- public class JsonUtiles
- {
- public static void grabar(JSONArray array) {
- try {
- FileWriter file = new FileWriter("test.json");
- file.write(array.toString());
- file.flush();
- file.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public static String leer()
- {
- String contenido = "";
- try
- {
- contenido = new String(Files.readAllBytes(Paths.get("nuevo.json")));
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- return contenido;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment