package api.jisuapi.barcode; import api.util.HttpUtil; import net.sf.json.JSONObject; public class Generate { public static final String APPKEY = "your_appkey_here";// 你的appkey public static final String URL = "https://api.jisuapi.com/barcode/generate"; public static final String type = "ean13"; public static final String barcode = "6901236341056"; public static final String fontsize = "12"; public static final String dpi = "72"; public static final String scale = "2"; public static final String height = "40"; public static void Get() { String result = null; String url = URL + "?appkey=" + APPKEY + "&type=" + type + "&barcode=" + barcode + "&fontsize=" + fontsize + "&dpi=" + dpi + "&scale=" + scale + "&height=" + height; try { result = HttpUtil.sendGet(url, "utf-8"); JSONObject json = JSONObject.fromObject(result); if (json.getInt("status") != 0) { System.out.println(json.getString("msg")); } else { JSONObject resultarr = json.optJSONObject("result"); String type = resultarr.getString("type"); String fontsize = resultarr.getString("fontsize"); String dpi = resultarr.getString("dpi"); String scale = resultarr.getString("scale"); String height = resultarr.getString("height"); String barcode = resultarr.getString("barcode"); System.out.println(type + " " + fontsize + " " + dpi + " " + scale + " " + height + " " + barcode); } } catch (Exception e) { e.printStackTrace(); } } }