public void printerInfo() { ? ?System.out.println("愛的發發達發達的說"); ?URL url = null; ? ?String uslStr = "http://192.168.0.106:8080/manage/typer/save.shtml"; ? ?try { ? ? ? ?url = new URL(uslStr); ? ? ? ?try { ? ? ? ? ? ?PrecisionPrint precisionPrint = new PrecisionPrint(); ? ? ? ? ? ?JSONObject jsonObject = precisionPrint.getPrintMSg(); ? ? ? ? ? ?URLConnection urlConnection = url.openConnection(); ? ? ? ? ? ?urlConnection.setRequestProperty("content-type", "application/x-www-form-urlencoded"); ? ? ? ? ? ?urlConnection.setDoOutput(true); ? ? ? ? ? ?urlConnection.setDoInput(true); ? ? ? ? ? ?OutputStream out = urlConnection.getOutputStream(); ? ? ? ? ? ?out.write(jsonObject.toString().getBytes("utf-8")); ? ? ? ? ? ?out.flush(); ? ? ? ? ? ?out.close(); ? ? ? ? ? ?// 從服務器讀取響應 ? ? ? ? ? // InputStream inputStream = urlConnection.getInputStream(); ? ? ? ? ? ?//String body = IOUtils.toString(inputStream, "utf-8"); ? ? ? ? ? ?//System.out.println("返回的值是:" + body); ? ? ? ?} catch (Exception e) { ? ? ? ? ? ?e.printStackTrace(); ? ? ? ?} ? ?} catch (MalformedURLException e) { ? ? ? ?e.printStackTrace(); ? ?}}
添加回答
舉報
0/150
提交
取消