1

这段代码给了我内容,但是一些俄罗斯字符为我隐藏了正方形......谁知道如何设置 utf-8 或 cp1251 字符集作为代理来获取内容。与代码共舞不会为我带来任何结果。getBytes 和其他方法不能给我正常的结果。

URL url = new URL(linkCar);
String your_proxy_host = new String(proxys.getValueAt(xProxy, 1).toString());
int your_proxy_port = Integer.parseInt(proxys.getValueAt(xProxy, 2).toString());
Proxy proxy = null;
System.out.println(proxys.getValueAt(xProxy, 3).toString());
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(your_proxy_host, your_proxy_port));
HttpURLConnection connection = (HttpURLConnection)url.openConnection(proxy);
connection.setConnectTimeout(16000);
connection.connect();

proxys - 代理列表的表模型;可能谁知道如何设置 connect throw socks-proxy

4

1 回答 1

1

对于 UTF-8,尝试换行

BufferedReader buffer_input = new BufferedReader(new InputStreamReader(connection.getInputStream()));

BufferedReader buffer_input = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));

如果要更改字符集,可以将字符集名称更改为另一个名称。

于 2012-08-25T19:14:10.107 回答