新手求教,不明白为什么不能把全部数据写进去。
import java.net.*;
import java.io.*;
public class TestUrlConnection {
public static void main(String[] args) {
BufferedReader reader = null;
HttpURLConnection connection = null;
try {
// 新建一个URL对象,指定到请求的url.
URL url = new URL("http://quote.tool.hexun.com/hqzx/quote.aspx?type=2&market=0&sorttype=3&updown=up&page=1&count=20000");
connection = (HttpURLConnection) url.openConnection();
File f = new File("stock.txt");
FileOutputStream fOut = new FileOutputStream(f);
PrintWriter p = new PrintWriter(fOut);
reader = new BufferedReader(new InputStreamReader(connection
.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
//System.out.println(line);
line=line.replace("dataArr = [", "");
line=line.replace("[", "");
line=line.replace("],", "");
p.println(line);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
connection.disconnect();
}
}
}
import java.io.*;
public class TestUrlConnection {
public static void main(String[] args) {
BufferedReader reader = null;
HttpURLConnection connection = null;
try {
// 新建一个URL对象,指定到请求的url.
URL url = new URL("http://quote.tool.hexun.com/hqzx/quote.aspx?type=2&market=0&sorttype=3&updown=up&page=1&count=20000");
connection = (HttpURLConnection) url.openConnection();
File f = new File("stock.txt");
FileOutputStream fOut = new FileOutputStream(f);
PrintWriter p = new PrintWriter(fOut);
reader = new BufferedReader(new InputStreamReader(connection
.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
//System.out.println(line);
line=line.replace("dataArr = [", "");
line=line.replace("[", "");
line=line.replace("],", "");
p.println(line);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
connection.disconnect();
}
}
}
...全文
相关推荐
英语学习 提高英语归功于 不能不能明白你们能不明白呢
学习能不不能不能明白你们部门呢你们不能不能明白你们不能明白你们不能不买你们能不能明
java 每个新手都要搞懂弄明白的
java 每个新手都要搞懂弄明白的,建议大家都看看.
vue中使用v-for时为什么不能用index作为key
主要介绍了vue中使用v-for时为什么不能用index作为key,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
写入数据,利用循环,把-10写入到0020H中,然后把-10和0020H不断加1,从而实现了把30个数据写进去
写入数据,利用循环,把-10写入到0020H中,然后把-10和0020H不断加1,从而实现了把30个数据写进去
中断为什么不能睡眠
详细分析linux操作系统中 的中断为什么不能睡眠原因。



