1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package epson.print;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.Serializable;
- public class EPPrinterInfo implements Serializable {
- static final long serialVersionUID = -4712510101292698959L;
- public String printerAccessKey = "";
- public String printerEmailAddress = "";
- public String printerID = "";
- public String printerIP = "";
- public int printerLocation = 0;
- public String printerName = "";
- public String printerSerialNo = "";
- public String scannerID = "";
- public String userDefName = "";
- public void writeJSON(FileOutputStream fileOutputStream) throws JSONException, IOException {
- JSONObject jSONObject = new JSONObject();
- jSONObject.put("printerName", printerName);
- jSONObject.put("printerID", printerID);
- jSONObject.put("printerIP", printerIP);
- String str = printerSerialNo;
- if (str == null) {
- str = "";
- }
- jSONObject.put("printerSerialNo", str);
- jSONObject.put("printerLocation", printerLocation);
- jSONObject.put("printerEmailAddress", printerEmailAddress);
- jSONObject.put("printerAccessKey", printerAccessKey);
- jSONObject.put("userDefName", userDefName);
- jSONObject.put("scannerID", scannerID);
- fileOutputStream.write(jSONObject.toString().getBytes());
- }
- public void readJSON(FileInputStream fileInputStream) throws JSONException, IOException {
- byte[] bArr = new byte[fileInputStream.available()];
- fileInputStream.read(bArr);
- JSONObject jSONObject = new JSONObject(new String(bArr));
- printerName = jSONObject.getString("printerName");
- printerID = jSONObject.getString("printerID");
- printerIP = jSONObject.getString("printerIP");
- printerSerialNo = jSONObject.getString("printerSerialNo");
- printerLocation = jSONObject.getInt("printerLocation");
- printerEmailAddress = jSONObject.getString("printerEmailAddress");
- printerAccessKey = jSONObject.getString("printerAccessKey");
- userDefName = jSONObject.getString("userDefName");
- try {
- scannerID = jSONObject.getString("scannerID");
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }
|