Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 678285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:07:57+00:00 2026-05-14T01:07:57+00:00

I have some JPG files that need to be replaced at runtime with a

  • 0

I have some JPG files that need to be replaced at runtime with a JFIF standardized version of themselves (we are using a vendor that gives us JPG that do not have proper headers so they don’t work in certain applications)… I am able to create a new file from the existing image, then get a buffered image from that file and write the contents right back into the file without having to delete it and it works…

imageSrcFolder.eachFileMatch ( ~/.*\.jpg/, {
    BufferedImage bi = ImageIO.read( it )
    ImageIO.write( bi, "jpg", it )
});

The question I have is why? Why doesn’t the file end up doubled in size? Why don’t I have to delete it first? Why am I able to take a file object to an existing file and then treat it as if it were a brand new one? It seems that what I consider to be a “file” is not what the File object in java actually is, or else this wouldn’t work at all.

My code does exactly what I want it to do, but I’m not convinced it always will… it just seems way too easy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:07:58+00:00Added an answer on May 14, 2026 at 1:07 am

    The JavaDoc for ImageIO.write includes this phrase:

    Writes an image using an arbitrary
    ImageWriter that supports the given
    format to a File. If there is already
    a File present, its contents are
    discarded.

    This is assuming that it is a File, as you used it in both the read and write operations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some large JPG files that need to be downsampled in an android
I have some files that have names like this: 'abcdefg_y_zz.jpg' The 'abcdefg' is a
I have a whole bunch of jpg files that I need to use in
I have some jpg files i want to create gif animated from them. i
I have a zip file that contains folder hierarchies and files. \images\ \images\1.jpg \images\2.jpg
I have a html file with some variable arrays that I need to increment.
I have some files to scan with patterns using preg_match like: File name: (a
I have an external PHP file that does some image resizing (image.php). I need
We have an url like http://site.s3.amazonaws.com/images/some image @name.jpg inside $string What I'm trying to
I have some data loaded as a np.ndarray and need to convert it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.