Get html code and save it to disk

Hi! I have a question... Does anyone know, how can I save the html source code of a web page through java code? I want to do the following thing:
1. give the url an get the html page
2. save the html page source code
-both functions should be in one class..
Thanks a lot

private void httpResponse2File(java.net.URL url, java.io.File file) throws Exception{
java.net.HttpURLConnection newConn = new sun.net.www.protocol.http.HttpURLConnection(url, null, 0);
newConn.setRequestMethod("GET");
newConn.connect();
int responseCode = newConn.getResponseCode();
if(responseCode == 200) {
java.io.FileOutputStream out = new java.io.FileOutputStream(file);
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(newConn.getInputStream()));
int contentLength = newConn.getContentLength();
String nextLine = null;
while((nextLine = in.readLine()) != null)
out.write((nextLine+"\r\n").getBytes());
in.close();
newConn.disconnect();
out.close();
}

Similar Messages

  • Get HTML spool and save it as html on a server directory (in batch)

    Hi all,
    I wrote a program which permits to get a spool an send it per mail as attachment or save it as file in a directory.
    It musst be available to start the program in batch mode.
    I've no problem to get the spool (type HTML) and send it via mail with the HTML file as attachment.
    But by getting the spool and saving it in a directory insteed sending it via mail, I've a corrupted file. Does anybody know how to solve the problem ?
    I did following :
    get the spool :
    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
         EXPORTING
           rqident              = iv_spool
         IMPORTING
           real_type            = lv_real_type
         TABLES
           buffer               = lt_soli
    * convert the file :
      lt_solix = cl_bcs_convert=>soli_to_solix( lt_soli ).
    *Transfert the file:
        OPEN DATASET lv_dataset FOR OUTPUT IN LEGACY BINARY MODE.
       LOOP AT lt_solix INTO ls_solix.
         TRANSFER ls_solix TO lv_dataset.
       ENDLOOP.
       CLOSE DATASET lv_dataset.
    Some other informations :
    - I do not want a spool in text mode (RAW). I want to get the HTML file.
    - I allready tried to do an open dataset in text mode -> didn't work.
    thank in advance for any advice.
    Fred

    i'm sorry, i'm pretty dumb and missed the change into solix table.
    try give a look here
    Spool to HTML Function Module
    ABAP Utility : Print-Screen to HTML

  • When I enter an HTML code and try to save it on a website it doesn't work.

    When I enter an HTML code and try to save it on a website it doesn't work.
    == This happened ==
    Every time Firefox opened
    == I went onto a website called Stardoll

    I have the same problem(:
    My HTML's won't save how they are supposed to!

  • GETTING HTML CODE FOR A SLIDESHOW

    How can i get HTML CODE for a slideshow recently created using Photoshop Elements 8.  I also added AUDIO both from my own audio folder AND from PE8 audio selections.

    What operating system are you using?
    On a windows system, I think you need to use the Share>Online Album in the  PSE 8 Organizer and then save the result to disk to get something with HTML code.
    The standard create slide show only outputs as a pdf or a movie format file.

  • Read HTML tags and Save Images in web page

    I had problem with reading HTML tags and save all images in that page. I can source code in web page but I dont know how to Identifly the image tag ( IMG tag ). I think i want to use string tokenizer class.
    But i dont know how to use it in my problem. If any one know how to do it. reply this.

    cnapagoda wrote:
    I had problem with reading HTML tags and save all images in that page. I can source code in web page but I dont know how to Identifly the image tag ( IMG tag ). I think i want to use string tokenizer class.
    But i dont know how to use it in my problem. If any one know how to do it. reply this.If you have a big, long string with HTML content in it you might try splitting on a regex like so:
    String html = ...
    String[] imgTags = html.split("<img.*?>");[http://java.sun.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String)|http://java.sun.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String)]
    to get your image tag data and then parsing that to get the src attribute. You can either treat this problem as a big string-parsing problem, or getting some HTML DOM library and using that to structure the page as a tree for easier access.
    If you want more help you'll have to show the code you have so far. We can't write this for you.

  • How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?

    How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?  I would like them to open at the size they were previously resized like they used to in previous operating systems.  They currently open at a very small size and the first colum is only a few letters wide necessitating a resize practically every time one wants to use it.  Any help would be appreciated.

    hi Prasanth,
    select werks matnr from ZVSCHDRUN into table it_plant.
    sort it_plant by matnr werks.
    select
            vbeln
            posnr
            matnr
            werks
            erdat
            kbmeng
            vrkme
            from vbap
            into table it_vbap
            for all entries in it_plant
            where matnr = it_plant-matnr and
                  werks = it_plant-werks.
    and again i have to write one more select query for vbup.
    am i right?

  • HT201209 My wife purchased an iTunes gift card for me and I scratched off the back to get the code and when I entered it to redeem it told me that it had already been redeemed what do I do?

    My wife purchased an iTunes gift card for me and I scratched off the back to get the code and when I entered it to redeem it told me that it had already been redeemed what do I do?

    Try Here  >  http://support.apple.com/kb/TS1292
    If no joy...
    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    And there is this...
    http://www.apple.com/hk/en/support/itunes/store/giftcard/

  • I NEED MY UNBLOCKING CODE FOR MY IPHONE 4S ,I HAVE BEEN INCONTACT WITH MY SERVICE PROVIDER AND THEY CONFIRMED THEY HAVE SENT AN EMAIL TO YOURSELF TO GET THE CODE AND NOW I NEED TO CONTACT YOU MYSELF IS THIS CORRECT AS VODAFONE DO NOT SEEM TO BE HELPING ME

    I NEED MY UNBLOCKING CODE FOR MY IPHONE 4S ,I HAVE BEEN INCONTACT WITH MY SERVICE PROVIDER AND THEY CONFIRMED THEY HAVE SENT AN EMAIL TO YOURSELF TO GET THE CODE AND NOW I NEED TO CONTACT YOU MYSELF IS THIS CORRECT AS VODAFONE DO NOT SEEM TO BE HELPING ME

    There is no such thing as an unlock code for an iPhone. It's done by restoring the phone using iTunes

  • I am having trouble printing I have a connection to my printer wirelessly but does not print out the correct page I want.When I do print I get a bunch of pages more than is needed and also get a code and symbols please help I am jammed at work

    I am having trouble printing I have a connection to my printer wirelessly but does not print out the correct page I want.When I do print I get a bunch of pages more than is needed and also get a code and symbols please help I am jammed at work

    This can be the result of selecting the wrong driver. An older, unsupported laser printer will sometimes work with the generic Postscript driver.

  • How do we get register code and group ?

    ji,
    how do we get register code and group based on device category?

    Use the below FM to fetch the equipment number
    ISU_DET_DEVICE_FROM_DEVLOC                                           
    X_DEVLOC                =        device location  
    X_KEYDATE             =       sy-datum
    Then call the below function to get euipment details
    ISU_DB_EZWG_SELECT_METER   
    X_EQUNR        =                equnr 
    X_AB               =            sy-datum
    Alternately
    Pass device location in table Egerh & fetch the equipment and register group. Then pass equnr in table ETDZ to fetch register code.
    Edited by: vikrant guptarya on Jul 20, 2011 2:46 AM

  • Adobe Muse html code and Constant Contact

    Muse noobie question re: Adobe Muse html code and Constant Contact
    We use Constant Contact for our email marketing. We prefer to generate our own html code and insert into Constant Contact. It has worked great for us in the past and bypasses and somewhat cumbserome Constant Contact interface.
    We tried inserting html code from Muse and the results were surprising:
    Any rectangles created were simply gone. Not showing. No colors, no outlines just gone.
    Text formating was way off in size and fonts. Spacing issues too.
    Page not centered. It looks centered in various browsers
    Any suggestions please?

    It's not going to work.
    The HTML/CSS/JavaScript abilities and requirements for browsers are vastly different that those of e-mail clients. The output of Adobe Muse relies on external CSS files and JavaScript, both of which are not available in most e-mail clients.

  • I just got an Itunes giftcard and scratched off to get the code and thought I had redeemed it but I go to get songs and it said it is already redeemed but won't let me buy them? Don't know what is going on?

    I just got an Itunes giftcard and scratched off to get the code and thought I had redeemed it but went to get songs and it takes me back to the redeemed part and it says it is already redeemed but I can't buy the songs weird! help!

    You won't be able to change your rescue email address until you can answer 2 of your questions, you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down this page to update your rescue email address for potential future use : http://support.apple.com/kb/HT5312

  • How to get html code out of psd file????

    Hi, I have PS CS6, and just try to work with brackets. Because I can`t extract psd files in my ps version, did it with project parfait. Then I`ve sended that file or better copied the public link into brackets and found my psd file extracted in layers in there. What I miss is the html code, which I`m desperately looking for. So how do I get an html code out of that psd file to create a webpage with brackets, without buying a new ps version...  thanks a lot in advance !

    If you not too familiar with html, you can use the save as web command. When you open the dialog box, towards the bottom you will find preview in Brower. First it will show you the image, but if you scroll down you will see the sample html that was used to create that image in the browser.
    If you need to break it up some you can use slices. Each slice will be its own image.
    The html needs to point to that image on the server.
    This means you need to upload the html and all images to a server. It also means that you will need to manually edit the html so that it has the correct folder location on the server so it can find the images.
    It is one thing to make it work on your computer, it is another story to make sure it works from a server. Usually a typo is what keeps it from working correctly. So pay attention to the url, folders and file names. Keep in mind that folders and files are case sensitive.
    Good luck.

  • How to search files, get cells, loop, and save

    Howdy Folks, I'm another Applescript newbie in over my head. I'm working on a script to copy xl files into a master xl file. the files is a roster with student and class information. the number of students will vary. WIth help from a friend I have it about 80% where I want it. Need help with the rest. I hope its okay to ask multiple question about the script if not i do apoligize.
    when the script runs it asks for the location of the file. the files are titled Houston_Sam_DWI_Jan.xlsx. I have several files in a master folder that i am trying to get data from, but the script goes through one at a time.
    I know i need to loop it somehow to go through all of the files containing "DWI" in the title, I just don't know how to do it.
    the script is set up to get a range of cells, but there are other individual cells i need to copy like dates(C7), Instructor(H7), and location(C11). How do i get these individual cells and paste them to the master doc: Location(E7), Dates (F7), Instructor(G7) and have them repeat down the column as the number of students from each of the classes populates the list.
    finally, i have the master file name as annual report, the script does update the anual report file, but when it goes to save it creates a file named "sheet 1". i just want it to update the annual report file and save all changes.
    here is the script i am currently working with:
    set master_path to alias "Users:bs:Desktop:master:Annual Report.xlsx"
    get_all_files(master_path)
    on get_all_files(master_path)
              set example_path to choose file with prompt "Find an example file to work with"
    transfer_data(example_path, master_path)
    end get_all_files
    on transfer_data(child_path, master_path)
              tell application "Microsoft Excel"
                        set child_book to (open workbook workbook file name (child_path as string))
                        set child_doc to worksheet 1 of child_book
                        set master to worksheet 1 of (open workbook workbook file name (master_path as string))
                        set num to 15 --All lists start at index 12 or later, I'm putting 10 to be safe
                        set students to {}
                        tell child_doc --grab values from child document
                                  repeat until (value of cell (("A" & num) as string)) is 1
                                            set num to num + 1
                                  end repeat
                                  repeat until (value of cell (("B" & num) as string)) is ""
                                            set end of students to {name:(value of cell (("B" & num) as string)), driver_id:(value of cell (("C" & num) as string)), DOB:(value of cell (("D" & num) as string)), pre_test:(value of cell (("J" & num) as string)), post_test:(value of cell (("K" & num) as string)), cert_id:(value of cell (("L" & num) as string))}
                                            set num to num + 1
                                  end repeat
                        end tell
                        tell master
                                  set num to 7
                                  log (value of cell (("B" & num) as string))
                                  repeat until (value of cell (("B" & num) as string)) is ""
                                            set num to num + 1
                                  end repeat
                                  repeat with student in students
                                            set value of cell (("B" & num) as string) to name of student
                                            set value of cell (("C" & num) as string) to driver_id of student
                                            set value of cell (("D" & num) as string) to DOB of student
                                            set value of cell (("H" & num) as string) to pre_test of student
                                            set value of cell (("I" & num) as string) to post_test of student
                                            set value of cell (("J" & num) as string) to cert_id of student
                                            set num to num + 1
                                  end repeat
      save master
                        end tell
      save child_book
      close child_book
      save active workbook in master_path
      close active workbook
              end tell
    end transfer_data
    Any help would be greatly appreciated.

    That did it. had to tinker with it but it's doing what i want. Thanks for all of the help. here is the final code
    tell application "Finder"
              set master_path to alias "Users:bs:Desktop:master:Annual Report.xlsx"
              set filesWithDWI to get every file of folder ((path to desktop folder) & "master" as string) whose name contains "DWI"
              repeat with f in filesWithDWI
                        my transfer_data(f, master_path)
              end repeat
    end tell
    on processfile(f)
    display dialog f as string
    end processfile
    on transfer_data(child_path, master_path)
              tell application "Microsoft Excel"
                        set child_book to (open workbook workbook file name (child_path as string))
                        set child_doc to worksheet 1 of child_book
                        set master to worksheet "sheet 1" of (open workbook workbook file name (master_path as string))
                        set num to 15 --All lists start at index 12 or later, I'm putting 10 to be safe
                        set students to {}
                        tell child_doc --grab values from child document
                                  repeat until (value of cell (("A" & num) as string)) is 1
                                            set num to num + 1
                                  end repeat
                                  repeat until (value of cell (("B" & num) as string)) is ""
                                            set end of students to {namevalue of cell (("B" & num) as string)), driver_idvalue of cell (("C" & num) as string)), DOBvalue of cell (("D" & num) as string)), pre_testvalue of cell (("J" & num) as string)), post_testvalue of cell (("K" & num) as string)), cert_idvalue of cell (("L" & num) as string))}
                                            set num to num + 1
                                  end repeat
                                  set startdate to range "C7"
                                  set classlocation to range "C11"
                                  set instructor to range "H7"
                        end tell
                        tell master
                                  set num to 7
                                  log (value of cell (("B" & num) as string))
                                  repeat until (value of cell (("B" & num) as string)) is ""
                                            set num to num + 1
                                  end repeat
                                  repeat with student in students
                                            set value of cell (("B" & num) as string) to name of student
                                            set value of cell (("C" & num) as string) to driver_id of student
                                            set value of cell (("D" & num) as string) to DOB of student
                                            set value of cell (("H" & num) as string) to pre_test of student
                                            set value of cell (("I" & num) as string) to post_test of student
                                            set value of cell (("J" & num) as string) to cert_id of student
                                            set value of cell (("f" & num) as string) to startdate
                                            set value of cell (("E" & num) as string) to classlocation
                                            set value of cell (("G" & num) as string) to instructor
                                            set num to num + 1
                                  end repeat
                        end tell
      save child_book
      close child_book
      save active workbook in master_path
      close active workbook
              end tell
    end transfer_data

  • [CS3] HTML Code and JS

    Hi,
    I exported a html page from Flash CS3. When I take a look at
    it in DW
    CS3 it shows me some code that I don't understand.
    There is a Flash detection js file linked to the html page.
    Is it
    recommended to use this? What does it do if no plugin is
    installed?
    And why is the object and embed tag inside a noscript tag?
    Does this
    make any sense?
    I want to include my flash page into a cms system so I want
    deliver a
    clean html page.
    Thanks for any help

    Remove all that code and learn this technique:
    http://blog.deconcept.com/swfobject/
    This is the best way (IMO) to get vaild HTML and XHTML with
    Flash content, and it also is very search engine friendly.

Maybe you are looking for