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 3797710
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:26:53+00:00 2026-05-19T13:26:53+00:00

There is a piece of project dealing mostly with input/output streams. So I have

  • 0

There is a piece of project dealing mostly with input/output streams. So I have to pass streams as arguments and receive them from third-party libraries. I’ve read Good design: How to pass InputStreams as argument? and Closing Java InputStreams, but I’m not 100% sure that third-parties are sharing the same coding values and following best designs patterns (in particular – “the one who opens the stream should close the stream”)

Assuming that streams are pretty big (500Mb – 3Gb) and I’m tight on CPU and memory resources, here are few questions to the java SO community:

  1. Should I ever try to close streams I got from third-party library?
  2. What are possible dangerous implications of unclosed streams (not counting extra GC workload)
  3. Are these implications somewhat proportional to the stream size?
  • 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-19T13:26:54+00:00Added an answer on May 19, 2026 at 1:26 pm
    1. You should close the stream when it reaches the end. If the passing library doesn’t want you do this, it should wrap the stream to ignore the close().
    2. Unclosed streams leave resources open, e.g. a file which is open cannot be deleted.
    3. The size is not important.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code from a book. There is this function
I have a piece of code from an old project. The logic (in a
you must have seen this piece of code somewhere else too,but obviously there's no
I have build.xml for my project, but even this small piece of code <target
In my current project, I have two models, Version and Comment. There is a
I have a project that is for a piece of software. So I reference
I've found a strange looking piece of code in a project I have to
In my project I have to get the barcode type from its barcode number.
I'm refactoring some piece of... code, part of huge, complex .Net project. There is
I have an piece of code that does calculations on assets. There are many

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.