Here you can find the source of downloadText(String url)
Parameter | Description |
---|---|
url | The url to download from. |
Parameter | Description |
---|---|
IOException | an exception |
public static String downloadText(String url) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.net.URL; import java.util.Scanner; public class Main { /**/* w w w .j a va2s. c om*/ * Download text from a string url. * * @param url The url to download from. * @return The text from the webpage. * @throws IOException */ public static String downloadText(String url) throws IOException { return downloadText(new URL(url)); } /** * Download text from a {@link URL}. * * @param url The url to download from. * @return The text from the webpage. * @throws IOException */ public static String downloadText(URL url) throws IOException { return new Scanner(url.openStream()).useDelimiter("\\A").next(); } }