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 net.minecraft.client; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.Collection; import java.util.Date; import net.minecraft.client.versions.CompleteVersion; /** * * @author Taconut */ public class versionRqst { protected Gson gson; public versionRqst() { GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory()); builder.registerTypeAdapter(Date.class, new DateTypeAdapter()); builder.enableComplexMapKeySerialization(); builder.setPrettyPrinting(); this.gson = builder.create(); } public Object[] getRQF(File versionTarget) { String jsonFile = ""; String jsonItem; CompleteVersion verver; Collection<File> reqLib = null; try { String verPath = versionTarget.getPath() + File.separator + "versions" + File.separator + VersionInfo.getModpackName() + File.separator + VersionInfo.getModpackName() + ".json"; BufferedReader reader = new BufferedReader(new FileReader(verPath)); String line = ""; while ((line = reader.readLine()) != null) { jsonFile += line; } reader.close(); //jsonFile = new FileInputStream(new File(versionTarget.getPath() + File.separator + VersionInfo.getModpackName() + ".json")); jsonItem = jsonFile.toString().replaceAll("\\r\\n", "\r").replaceAll("\\r", "\n"); verver = (CompleteVersion) gson.fromJson(jsonItem, CompleteVersion.class); reqLib = verver.getClassPath(OperatingSystem.getCurrentPlatform(), versionTarget); Object[] rqfOut = new Object[2]; rqfOut[0] = verver; rqfOut[1] = reqLib; return rqfOut; } catch (Exception e) { e.printStackTrace(); } return null; } }