Results 1 to 5 of 5
  1. #1
    paras is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

    Unhappy Image reading from URL problem

    I have an image that I need to read from a URL.
    However, I want to make it so that this can be interrupted anytime I want, even if it's in the middle of reading an image, for performance reasons.
    I am using ImageIO.read(), which seems to be a blocking operation.
    Is there any solution that can fix this problem?
    thank you
    -paras

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    12

    Default

    Do you want to be able to interrupt the download or the conversion?

    For the former you can first read the data into a ByteBuffer or similar in chunks, then call ImageIO.read() on a stream from the buffer once all the data has been downloaded.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    paras is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

    Default

    yep, it's a download
    thank you :)

    I will try this solution.
    Just 1 question, though
    How would I get a stream from the buffer?

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    12

    Default

    ByteArrayInputStream and ByteArrayOutputStream can be used with just a regular byte[].
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    paras is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

Similar Threads

  1. [SOLVED] Image reading from URL problem
    By paras in forum New To Java
    Replies: 3
    Last Post: 04-18-2009, 05:11 AM
  2. Weird path problem when reading properties file
    By jerry_popperq in forum New To Java
    Replies: 0
    Last Post: 03-18-2009, 03:32 PM
  3. Problem with reading text from a .txt file
    By Gigi in forum New To Java
    Replies: 40
    Last Post: 01-22-2009, 03:22 AM
  4. reading textfile from java problem
    By saytri in forum New To Java
    Replies: 1
    Last Post: 01-17-2008, 02:13 AM
  5. Problem reading an xml file with AJAX
    By Fiona80 in forum XML
    Replies: 0
    Last Post: 12-17-2007, 08:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •