讀取Tomcate的txt檔案
阿新 • • 發佈:2019-01-29
new Thread(){ @Override public void run() { try { String wj = URLEncoder.encode(biaoti , "utf-8");//轉碼,不然url不能識別中文 URL url = new URL("http://"+ IpDuanKou.ip_fuwuqi+"/YunZhiApp/shiping/mulu/"+wj+".txt"); InputStream in = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(in ,"GB2312"));//對中文 String line; Shuju.spmulu = "";//清空 while((line = br.readLine()) != null){ Shuju.spmulu += "\n" + line; } handler.sendEmptyMessage(1); in.close(); br.close(); } catch (IOException e) { e.printStackTrace(); } } }.start();