Results 1 to 2 of 2
  1. #1
    reverton is offline Member
    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0

    Default Read an image an write one back

    I am trying to read an image the I have already put in my package and then write another file with the same picture. There are no errors, but it is not writing the new file:
    Java Code:
    	public static void main(String[] args) {
    		try {
    			BufferedImage image = ImageIO.read(new File("IMG_0146.jpg"));
    			ImageIO.write(image, "jpg", new File("uts.jpg"));
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    Last edited by JosAH; 05-11-2013 at 11:40 AM. Reason: fixed the [code] ... [/code] tags

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Read an image an write one back

    Create the File object first, and then print the value of getAbsolutePath().
    That will tell you (at least) where it is going to try and save the image.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. XML read/write in Java
    By bogdy.laurentiu in forum XML
    Replies: 5
    Last Post: 05-31-2010, 06:08 PM
  2. Read/Write Files
    By FlyNn in forum New To Java
    Replies: 3
    Last Post: 02-06-2010, 08:45 PM
  3. How to read first 9 bytes and write in...?
    By aRTx in forum New To Java
    Replies: 8
    Last Post: 03-26-2009, 02:54 PM
  4. Saved files are coming back as read-only
    By Manoeuvre in forum Eclipse
    Replies: 0
    Last Post: 11-21-2008, 05:18 PM
  5. Read and Write file
    By mrdestroy in forum New To Java
    Replies: 13
    Last Post: 10-31-2008, 12:11 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
  •