piffy icon

FetchHTML

piffy | PRO | 10/31/21 08:57:52 AM UTC | 0 ⭐ | 1240 👁️ | Never ⏰ | []
Java |

730 B

|

None

|

0 👍

/

0 👎

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
 
public class FetchHTML {
 
    protected  String HTML;
    protected  String theURL;
 
    public FetchHTML(String theURL) throws IOException {
        this.theURL=theURL;
        this.theURL="";
    }
 
    protected void fetch() throws IOException {
         URL url = new URL(theURL);
        InputStream is = url.openStream();
        int ptr = 0;
        StringBuffer buffer = new StringBuffer();
        while ((ptr = is.read()) != -1) {
            buffer.append((char)ptr);
        }
        HTML=buffer.toString();
    }
 
    @Override
    public String toString() {
        return HTML;
    }
 
}
 

Comments