public static void main(String[] args) throws IOException { URL url = new URL("这里是网址"); URLConnection conn = url.openConnection();// 获得UrlConnection 连接对象 InputStream is = conn.getInputStream();// 获得输入流 BufferedReader br = new BufferedReader(new InputStreamReader(is));// buffered表示缓冲类 String str; FileWriter fw = null; while ((str = br.readLine()) != null) { fw = new FileWriter("D:\\1.txt"); System.out.println(str); fw.write(str); fw.flush(); } fw.close(); }
求大神们赐教
Caballarii
相关分类