Save photos from a web page

Hello everybody:
I'd like to save a photograph taken from a web page as a jpg file. I have written the following application, but It doesn�t work.
public static void main(String[] args) {
try {
URL url = new URL ("http://ia.imdb.com/media/imdb/01/I/68/65/38m.jpg");
URLConnection connection = url.openConnection();
DataInputStream inStream = new DataInputStream(connection.getInputStream());
String inputLine;
File outFile = new File("fotoTomHanks.jpg");
PrintWriter outStream = new PrintWriter(new FileWriter(outFile));
while ((inputLine=inStream.readLine())!=null) {
     outStream.println(inputLine);
inStream.close();
outStream.close();
} catch (MalformedURLException me) {
System.err.println("MalformedURLException: " + me);
} catch (IOException ioe) {
System.err.println("IOException: " + ioe);
I think I'm not using the correct streams or writers because I'm doing the same i would do if I'd like to save a string in a txt file, but I don�t know how I should do it.
Thank you in antitipation for your help.

Repeat after me:
Readers/writers are for text data.
Streams are for binnary data.
JPEGs don't have text lines.To further expound:
*A low-level stream receives and writes bytes.
*A high-level filter stream typically receives and writes primitive types such as doubles, ints, or UTF.
*Readers and writers can be thought of as specialized filter streams for reading and writing units of Unicode characters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Blocking the ability to download a photo from a web page using iWeb

    You guys have been so helpful about helping me make video files and music tracks unavailable for downloading from my site by altering the javascript code on my iDisc. Now I have another problem.
    The photo/pictures placeholders in iWeb permit me to place photos on my web pages. Is there a way to alter the code so that the option to drag-copy or download the picture from my site can be disabled?
    Thanks for your help!
    Jim

    Here are some variations that make messing with strings easier.
    $LocalPage ='\\server\share\sam1.html'
    # build URI
    $template= 'https://server/reports/116/output/?start-year={0}&start-month={1}&start-day={2}&days=1&company-code=1'
    $d=[datetime]::Today.AddDays(-1)
    $uri=$template -f ($d.Year-2000),$d.Month,$d.Day
    (Invoke-WebRequest -Uri $uri).Content | Out-File -FilePath $LocalPage -Force
    & $LocalPage
    ¯\_(ツ)_/¯
     Nice!
    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
    Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

  • Right clicking to save photos from web source

    I am trying to save PICS from a web-site and I am stumped about the "right-click." What is the Mac substitute for this command?
    It is a subscription service so I can't send you the URL.
    If you'd like to save photos to your computer, simply hold the cursor over one of slideshow pictures and select Visit Gallery. From there, you'll be able to download individual ones by opening a photo, right-clicking, and selecting Download This Photo.

    On a Mac, right-clicking is done by holding down the control key when you click on the image or file.
    Alternatively, just dragging the image to your desktop usually does the trick.

  • How to save an image from an web page?

    Hello everybody!
    I have a problem and I hope someone can help me :).
    I am trying to save/download an image from an web page to my computer. So given an URL which contains the image, I want to save this/write this image to disk. Here is my code:
    import java.net.*;
    import java.io.*;
    public class Test{
        public static void main(String[] args) throws Exception{
            Test test = new Test();
            test.readFile();
        public void readFile() throws Exception{
            InputStream inputStream = new URL("http://www.google.se/images/hp1.gif").openStream();
            InputStreamReader reader = new InputStreamReader(inputStream);
            BufferedReader buffReader = new BufferedReader(reader);
            BufferedWriter bw = new BufferedWriter(new FileWriter("savedImage.gif"));
            int x=0;
            while((x = buffReader.read()) != -1) {
                bw.write(x);
            bw.flush();
    }The code saves the image to disk, but unfortunately the image is distorted. Can anyone help me to solve this problem.
    Thanx in advance
    Best regards
    /TheMan

    thanx guys for your quick answers. I got i to work with the following code
    InputStream inputStream = new URL("http://www.google.se/images/hp1.gif").openStream();
            FileOutputStream fos = new FileOutputStream(new File("savedImage.gif"));
            int x=0;
            while((x = inputStream.read()) != -1) {
                fos.write(x);
            fos.flush();Again, thanx guys!

  • I did a COPY of some text from a web page, and then did a PASTE into notepad.exe (Windows). The text from each line was duplicated -- on the line! Instead of "Fred", it became "Fred Fred".

    I just recently installed Firefox for the first time. It seems nice and quick. The version is reported as: "10.0.1".
    I wanted to save some text from a web page, so navigated to that page, selected the text, and pressed the Control-C combination to COPY the selected text to the buffer. For example, the text I selected looked something like this:
    Harry
    Ron
    Hermione
    Hagrid
    Albus
    NOTE: Each line of text has a small icon to the left of the text.
    It is not reasonable to COPY and PASTE each line individually, as there can be hundreds of lines of data. I recall, however, that
    doing a COPY and PASTE on this data into Microsoft's Excel will produce cells which have the icons included in the cell, but unfortunately one cannot can't get rid of them! At least I've never found a way to remove them, but that's another issue. :)
    Once I'd done the COPY operation I switched to a Notepad window and did a PASTE operation. To my surprise, the text from each line was duplicated. It looked like this:
    Harry Harry
    Ron Ron
    Hermione Hermione
    Hagrid Hagrid
    Albus Albus
    Thinking that there might be something unusual about the web page I looked at the source, but it appeared "normal" -- that is, as expected.
    Note: I have done this operation several times before, and have never seen this occur before.
    Note: In the actual data some of the lines have quoted text in them. Curiously there is weird behavior on these lines. In some cases the entire line is shown only once. (These occur at the top of the line, and the quoted text is at the beginning of the name.)
    When quoted text appears "later" in the name, in some cases the quoted text is duplicated, and in other cases the quoted text is missing altogether! I have also noticed an error with the quoted text, and so will be reporting that to the web site which generates the HTML.
    Note that each line of "text" is "anchor text", so if I click on a name the browser navigates to a page for that name.
    I believe that the problem is that the COPY operating in Firefox is not simply copying the visible text, but also the ALT=
    Below is a sample of what the source HTML looks like:
    <a class="lnk" target="_blank" href="http://details.aspx?id=Harry">
    <img width="16" height="16" alt="Harry" class="tb_icon" src="http://.../Harry.gif"/>
    <span>Harry</span></a>
    <br/>
    (Because of the true length of the lines in the source HTML, I have stripped out the actual URL of the site.)
    To make sure I wasn't imaging this difference I repeated the process within Internet Explorer. In that browser I did not get duplicated data.

    Try:
    *Extended Copy Menu (fix version): https://addons.mozilla.org/firefox/addon/extended-copy-menu-fix-vers/

  • Using Adobe Pro X I cannot create a PDF from a web page.

    After a recent upgrade from a previous version of Firefox, I am now unable to create a PDF from a web page using the Adobe Pro toolbar on the web page.  A "save as" box appears and then the conversion process dies.  I can print the page using Adobe Pro as my printer and it works fine. I can create other docs with Adobe Pro.   How do I fix this on my browser?
    Thanks.
    WSC

    Browser Troubleshooting
    "Can't view PDF on the web"
    http://helpx.adobe.com/acrobat/kb/cant-view-pdf-web.html
    "Display PDF in browser"
    http://helpx.adobe.com/acrobat/using/display-pdf-browser-acrobat-xi.html
    Be well...

  • Create a PDF from a Web Page

    I was on Acrobat pro 6.  Now I am trying out Acrobat X pro ("v10").
    1.  I create a pdf file from a web page.  When I click on a link in the new pdf file, it automatically opens that link in a web browser.  Previously, in v 6.x, it defaults to "Append to the Document".  How can I set Acrobat X Pro to default to "Append to Document" ?
    2.  I find the pdf file created from a web page has no page numbers.  Again, in v6.x, there was page numbers in those files.  How can I get page numbers included in the header/footer?  Is the header/footer configurable?
    3.  In v6.x, when I want to convert a web page (into pdf) that is behind a password -- because it includes links, whereas printing to pdf does not -- I would first get the login page (in pdf).  Then I can type in my password in the pdf file and click on go (right click and select Append) and I would get the next page in pdf.  Now, v10 no longer does that.  I keep getting different errors depending on the web site.  e.g. I was testing on this web site, and get "SyntaxError: invalid XML tag syntax".  Am I missing something or is there a "new" way to get the same result in v10?
    TIA

    Hi paulp14382584,
    It seems that you have removed the Create PDF from webpage tool from the toolbar by mistake. Please don't worry I will help you to get this issue fixed.
    1) Open the Acrobat on your computer.
    2) Right click on the toolbar & select Edit Current Tool Set form the list.
    3) Edit tool set window will pop up on your screen.
    4) Please Click on the 'Create'  option from the list on the left hand side & then select ' PDF from Web-page' from the drop down list.
    5) Then click on the small button ( + & arrow sign towards up ) to add it to the tool bar.
    6) Hit Save to confirm the changes.
    This will add the Create PDF from web-page tool on the tool bar.
    Let me know if you experience any issue.
    Regards,
    Aadesh

  • Suddenly, system produces a "microsoft image writer," freezes, then crashes when I try to print from a web page. This is new, just past week or so.

    For the past week or two, when I desire to print from a web page or email and hit the "print" command, instead of my printer name the printer window displays 'microsoft document image writer." Then it asks me to save (in which case it appears in my documents) or print to file. Then, if it works, it produces a window with an image of the page. And once or twice, I can then print. But usually, it produces a blank screen, an endless hourglass, a "not responding" message, and then the blue screen of death.

    -> Problems printing web pages
    * http://kb.mozillazine.org/Problems_printing_web_pages
    -> [Firefox hangs]]
    * http://kb.mozillazine.org/Firefox_hangs
    Check and tell if its working.

  • To automatically save photos from a website

    I would like to use Apple Script or Automator or something else to automatically copy and save photos from a website on my HD.
    There's a site with a great number of photos (museum showing photos, paintings, and other sites, all in JPEG) and I would like to create a program that will first open the thumbnail and once open as a large picture, will copy/save the photo to a specified folder on my HD, then go back to the page with the thumbnails and do the same with the second photo, then the third, and so on. And if possible to the next page after that. So I don't have to spend hours and hours doing this.
    After it is downloaded I will look what I want to keep and what I want to delete.
    How can I do this ?

    Thank you.
    There are many sites, but this one about photography is something I visit often:
    http://www.modelmayhem.com/list/279520
    If you click on one photo it will show it big in a different page. Notice on the left upper corner the word "portfolio", I would like to open this as well. (Usually it's one page with up to 20 photos although some people have up to 5 pages maximum).

  • Posting an XML Variable to a BLS Transaction from a web page

    I am working in xMII 11.5 with all the latest service packs. I know this is probably a really basic question but I am stumped.
    I am trying to pass a multi row and multi column XML data set from a web page into a BLS transaction (actually, two of them) in order to populate the parameter. I want to use the Web Service interface to the transaction. I have tried using parameters on an Xacute Query in an Applet as well with an equal lack of success. I cannot persuade the transaction to see the incoming variable as an XML data type. I have tried encoding and decoding and string to xml conversions and nothing seems to successfully allow the data set to be seen withing the BLS as anything but a string. The String to XML action will not handle the number of columns in the dataset though it seems to work if the data set has only one column. The data set is formatted in the proper "Rowsets/Rowset/Row" format. I have considered writing the data to an XML file on the server (I know I can deal with that) but that is not acceptable in this application.
    Can someone share the secret with me?
    ...Sparks

    Parameter value:
    r1d1,r1d2,r1d3;r2d1,r2d2,r2d3;r3d1,r3d2,r3d2
    Pass thru String List to Xml Parser with delim ";"
    <Row>
    <Item>r1d1,r1d2,r1d3</Item>
    </Row>
    <Row>
    <Item>r2d1,r2d2,r2d3</Item>
    </Row>
    <Row>
    <Item>r3d1,r3d2,r3d2</Item>
    </Row>
    Repeat on each row/item and pass thru String List to Xml Parser with delim ","
    <Row>
    <Item>r1d1</Item>
    </Row>
    <Row>
    <Item>r1d2</Item>
    </Row>
    <Row>
    <Item>r1d3</Item>
    </Row>
    Of course, your columns aren't flat but they are easy to ref, to get "column 2" for example:
    StringListToXml_1.Output{/Rowsets/Rowset/Row[2]/Item}
    So now you have rows and columns. Assign your data to your BAPI structured as needed.
    We have passed complex XML via the SOAP interface in 11.5, but it involved some "hacks". Basically we passed the sterilized XML via a String Type Parameter, and then unserialized it inside the BLT.  
    I have been told on this board that there is a solution to passing XML data vie the SOAP interface using ref docs, but i have never personally seen a working example.

  • How to read text from a web page

    I want to read text from a web page. Can any body tell me how to do it.

    Ok i tell you detail. visit the site " http://seriouswheels.com/" you will a index from A to Z which are basically car name index i want to read each page get car name and its model and store it in data base. I you can provide me the code i will be very thankful.

  • How to get the return values from a web page

    Hi all :
       how to get the return values from a web page ?  I mean how pass values betwen webflow and web page ?
    thank you very much
    Edited by: jingying Sony on Apr 15, 2010 6:15 AM
    Edited by: jingying Sony on Apr 15, 2010 6:18 AM

    Hi,
    What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
    Regards,
    Karri

  • How to download an animated .gif from a web page

    how do i download to my mac an animated gif that is on a web page....when i want a picture or text or something like that i just ...apple shift 4 and "take a picture of it" ...but i want the animation..i have never had to do that on this mac.....a windoze person from the site(chat site) said just right click but my wireless mac mouse doesnt do that....i would appreciate any help.....i do know how to down load from a site that has downloadable .gifs...you just click the download sign they have and no problem....but this is just a random animated .gif from a web page ....i hope my ques is clear....thank you

    Drag and drop it from the webpage onto your desktop. Note that it won't remain "animated" while you're looking at the file's icon, but it should work if you build it into a new website.
    And you can right-click with a Mac mouse - you just have to set it up to do so in System Preferences. (Set the right side of the mouse to be a "secondary click".)
    Matt

  • New Mac, fresh install of Mountain Lion When I click to open a .Pdf from a web page,while in Safar, I get a black window Nothing opens in Preview or in Acrobat No option to download

    New Mac, fresh install of Mountain Lion
    When I click to open a .Pdf from a web page,while in Safar, I get a black window
    Nothing opens in Preview or in Acrobat
    No option to download

    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Type of copy paste the following:
    /Library/Internet Plug-Ins
    Click Go. If you see this file:  AdobePDFViewer.plugin
    Drag it to the Trash, empty the Trash.
    Quit and relaunch Safari.

  • How to Open an Oracle Apps Screen from a web page

    Hi,
    We have requirement for Opening an Oracle Application screen (say sales order form) directly from a web page.
    I could get the URL of the required screen, but the URL contains an ICX_TICKET number, which is generated dynamically by Oracle Apps. So I can't use a static URL for this.
    Do you know how I can use or generate an ICX_TICKET in runtime? My user will have an active Oracle Application screen opened along with web page. He want to navigate to Oracle Apps screen from Web page. Hopes this makes the requirement more clear.
    Thanks for your time,
    Aneesh

    Hi Helios,
    I have identified a function to generate ICX_ticket. By appending this ticket, I am able to open the Oracle Apps screen. Now, is there in implication on the security side, if I go ahead this way?
    Function
    fnd_gfm.one_time_use_store(icx_sec.GetSessionCookie(CZ_CF_API.ICX_SESSION_TICKET),300,'FORMS_APPLET')
    Anyways, I am raising an SR as u suggested.
    Thank you,
    Aneesh

Maybe you are looking for

  • Importing from iMovie HD project

    I bought a new iMac and i'm importing in iMovie 08 a project from iMovie06. But i have 2 problems: first not all the clips are imported and second that the clips that are imported are not in the same order of the original projct. Does anyone have any

  • Printing in black and white in iPhoto/Preview

    Hello guys, I have real trouble trying to find how simply to choose print colour document in black and white from iPhoto or Preview. There is simply no option for that. Instead I open document with Chrome, or save photo as pdf and then open with Chro

  • Quarter Level Calculations

    Hi All, I am trying to write quarter level calculations but my base period is months. But i am not getting calculation option at the quarter level. Thankx in advance Edited by: user9174018 on Mar 11, 2010 2:02 AM

  • How to Copy backup to new ipad

    How to Copy backup to new ipad?

  • Multiple Float Paths

    I have a problem related to the multiple float paths. After marking the float path in the tools, schedule, advanced, multiple paths = 10, etc., the fields "Float Path" and "Float Path Order" remain empty. Can anybody give me a hint on what might have