Click here to Skip to main content
   

Java

 
QuestionWebpage saver -- help Pinmembercubocik13-Jan-13 8:38 
SuggestionRe: Webpage saver -- help PinmvpRichard MacCutchan13-Jan-13 23:18 
GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 6:51 
GeneralRe: Webpage saver -- help PinmvpRichard MacCutchan14-Jan-13 7:12 
You are missing a few #import statements, and you are also trying to read from your output stream. Try this:
import java.io.*;
import java.net.*;
 
public class webpagesaver{
    public static void main(String[] args) throws IOException{
    
        String saveFile = "PaginaCopiada.html"; //name of SaveFile
        String location = "http://www.sapo.pt"; // website url withou #
        URL url = new URL(location);
        URLConnection conn = url.openConnection();
        InputStream is = conn.getInputStream();
        conn.connect();
        BufferedWriter out = new BufferedWriter(new FileWriter(saveFile));
        BufferedReader in = new BufferedReader(new InputStreamReader(is));
        String l = in.readLine();
        while(l!=null){
            out.write(l);
            out.newLine();
        }
        in.close();
        out.close();
    }    
}
One of these days I'm going to think of a really clever signature.

GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 7:34 
GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 7:39 
GeneralRe: Webpage saver -- help PinmvpRichard MacCutchan14-Jan-13 7:55 
GeneralRe: Webpage saver -- help Pinmembercubocik14-Jan-13 8:55 
GeneralRe: Webpage saver -- help PinmvpRichard MacCutchan14-Jan-13 23:02 
GeneralRe: Webpage saver -- help Pinmembercubocik16-Jan-13 1:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 28 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid