当前位置: 技术问答>java相关
……………………………非常奇怪的问题。
来源: 互联网 发布时间:2015-07-31
本文导语: byte[] re_buffer = new byte[9000]; try{ URL u = new URL("http://www.csdn.net"); InputStream re_in = u.openStream(); int numberOfReBytesRead = re_in.read(re_buffer); ...
byte[] re_buffer = new byte[9000];
try{
URL u = new URL("http://www.csdn.net");
InputStream re_in = u.openStream();
int numberOfReBytesRead = re_in.read(re_buffer);
System.out.println(numberOfReBytesRead+"0000000000000000:"+re_in.available());
System.out.println("=============:"+new String(re_buffer,0,numberOfReBytesRead));
}catch(Exception e){
}
每次读到的字节都是2528,为什么啊???
try{
URL u = new URL("http://www.csdn.net");
InputStream re_in = u.openStream();
int numberOfReBytesRead = re_in.read(re_buffer);
System.out.println(numberOfReBytesRead+"0000000000000000:"+re_in.available());
System.out.println("=============:"+new String(re_buffer,0,numberOfReBytesRead));
}catch(Exception e){
}
每次读到的字节都是2528,为什么啊???
|
String ss;
try{
URL u = new URL("http://www.csdn.net");
InputStream re_in = u.openStream();
InputStreamReader reader = new InputStreamReader(re_in);
BufferedReader bufReader = new BufferedReader(reader);
while ((ss = bufReader.readLine()) != null)
{
System.out.println(ss);
}
}catch(Exception e){
}
这段程序可以,我也不清楚你的那段为什么不行:(
try{
URL u = new URL("http://www.csdn.net");
InputStream re_in = u.openStream();
InputStreamReader reader = new InputStreamReader(re_in);
BufferedReader bufReader = new BufferedReader(reader);
while ((ss = bufReader.readLine()) != null)
{
System.out.println(ss);
}
}catch(Exception e){
}
这段程序可以,我也不清楚你的那段为什么不行:(