URL url = new URL("http://192.168.1.1:8080/test.xml"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); BufferedInputStream in = new BufferedInputStream(connection.getInputStream()); in.readLine();
import java.io.*; import java.net.*; class Test { public static void main(String s[]) { int b; try { String str=""; URL url = new URL("http://192.168.1.1:8080/test.xml"); InputStream is = url.openStream(); BufferedInputStream bis = new BufferedInputStream(is);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
in.readLine();
import java.net.*;
class Test
{
public static void main(String s[])
{
int b;
try
{
String str="";
URL url = new URL("http://192.168.1.1:8080/test.xml");
InputStream is = url.openStream();
BufferedInputStream bis = new BufferedInputStream(is);
while((b=is.read())!=-1)
{
str = str+(char)b;
}
is.close();
bis.close();
str = new String(str.getBytes("ISO-8859-1"),"GB2312");
System.out.println (str);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}==========这样就搞定了,及时揭帖