Java 如何制作android应用程序,以编程方式下载web内容的特定部分?
我在我的项目中工作,需要使用网站内容的特定部分,而不是网站的全部数据。Java 如何制作android应用程序,以编程方式下载web内容的特定部分?,java,android,android-studio,download,web-content,Java,Android,Android Studio,Download,Web Content,我在我的项目中工作,需要使用网站内容的特定部分,而不是网站的全部数据。 在安卓系统中有什么方法可以做到这一点?我更喜欢在使用所需部分内容之后下载整个web数据。 首先下载这样的数据 public static void main(String[] args) { URL url; InputStream is = null; BufferedReader br; String line; try { url = new URL("
在安卓系统中有什么方法可以做到这一点?我更喜欢在使用所需部分内容之后下载整个web数据。 首先下载这样的数据
public static void main(String[] args) {
URL url;
InputStream is = null;
BufferedReader br;
String line;
try {
url = new URL("your.website/");
is = url.openStream(); // throws an IOException
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (is != null) is.close();
} catch (IOException ioe) {
// nothing to see here
}
}
}
之后,您可以使用行来收集所需数据。我更喜欢在使用所需部分内容之后下载整个web数据。 首先下载这样的数据
public static void main(String[] args) {
URL url;
InputStream is = null;
BufferedReader br;
String line;
try {
url = new URL("your.website/");
is = url.openStream(); // throws an IOException
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (is != null) is.close();
} catch (IOException ioe) {
// nothing to see here
}
}
}
之后,您可以使用行收集所需数据。简单HTTP请求如何?简单HTTP请求如何?