Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Json; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import org.json.simple.JSONObject; /** * * @author seryo */ public class Type { public Type(String type) { JSONObject obj = new JSONObject(); obj.put("type", type); File file = new File("type"); try { //?, ? ?? ? if (!file.exists()) { file.createNewFile(); } //PrintWriter ? ? ? PrintWriter out = new PrintWriter(file.getAbsoluteFile()); try { //? ? out.print(obj); } finally { //? // ?? out.close(); } } catch (IOException e) { throw new RuntimeException(e); } } public Type() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }