//傳送物件到遠端
URL url = new URL("遠端網址");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setDefaultUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectOutputStream ous = new ObjectOutputStream(urlConnection.getOutputStream());
ous.writeObject(cgsNums);
ous.writeObject(qcOrders);
ous.writeObject(cpdtOwner);
ous.flush();
ous.close();
//遠端將資料組合後
//讀取網頁
StringBuffer html = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
while ((inputLine = br.readLine()) != null) {
html.append(inputLine).append("\r\n");
}
沒有留言:
張貼留言