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

  • Home
  • SEARCH
  • 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 6673311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:36:46+00:00 2026-05-26T03:36:46+00:00

C# supports disposable pattern for deterministic garbage collection using the dispose pattern . Is

  • 0

C# supports disposable pattern for deterministic garbage collection using the dispose pattern.

Is there such pattern for java?

Java 7 has autoclosable, which you can use with try finally blocks to invoke the close method.

What about versions prior to 7?

Is there a disposable pattern (deterministic garbage collection) for Java 5 or 6?

  • 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-26T03:36:47+00:00Added an answer on May 26, 2026 at 3:36 am

    The closest prior to Java 7 is just “manual” try/finally blocks:

    FileInputStream input = new FileInputStream(...);
    try {
      // Use input
    } finally {
      input.close();
    }
    

    The using statement was one of the things I found nicest about C# when I first started using C# 1.0 from a Java background. It’s good to see it finally in Java 7 🙂

    You should also consider Closeables in Guava – it allows you to not worry about whether or not a reference is null (just like a using statement does) and optionally “logs and swallows” exceptions thrown when closing, to avoid any such exception from effectively “overwriting” an exception thrown from the try block.

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

Sidebar

Related Questions

Asciidoc supports callouts . How can one write similar callouts using reStructuredText ?
.NET supports the FlagsAttribute for enum's, which indicates that an enumeration can be treated
WebKit/Safari supports the console object, which is similar to what Firebug does. But what
pthread supports static initialization of pthread_mutex_t using PTHREAD_MUTEX_INITIALIZER. Is it possible to achieve a
LinqPad supports WCF Data Services. If you assign an URL, such as http://services.odata.org/Northwind/Northwind.svc/ .
MySQL supports events where i can set up something to happen in a specified
IIS7 supports this by using <system.webServer> configuration element to set module's preCondition=managedHandler attribute. Since
FullCalendar supports taking in a JSON object through AJAX for it's events, this can
Oracle supports a query syntax where a table is joined to an Oracle collection
I have a MVC app using the UnitOfWork, Service Layer, Repository Pattern and EF4

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.