JAvaリモート読み出しストリームファイル
1152 ワード
public String getYCFile(String urlPath) {
String readStr = "";
try {
try {
String strUrl = urlPath.trim();
URL url = new URL(strUrl);
HttpURLConnection urlCon = (HttpURLConnection) url.openConnection();
urlCon.setConnectTimeout(10000);
urlCon.setReadTimeout(30000);
BufferedReader in = new BufferedReader(new InputStreamReader(
urlCon.getInputStream(), "GBK"));
String inputLine = " ";
while ((inputLine = in.readLine()) != null) {
readStr += inputLine.trim();
}
in.close();
return readStr;
} catch (IOException e) {
readStr = "";
}
} catch (Exception e) {
readStr = "";
}
return readStr;
}
ファイルhttpのurlさえ読めばStringにつなぎ合わせる