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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:04:29+00:00 2026-06-15T19:04:29+00:00

I read from an input stream and in my finally block try to close

  • 0

I read from an input stream and in my finally block try to close it by calling in.close();
However the execution of main gets blocked . What is the way out ?

On suggestion , the code I used is ,

if (!processed) {
                System.out.println("in processed");
                byte[] contents = new byte[(int) fileSplit.getLength()];
                Path file = fileSplit.getPath();
                FileSystem fs = file.getFileSystem(conf);
                FSDataInputStream in = null;
                try {
                    in = fs.open(file);
                    IOUtils.readFully(in, contents, 0, contents.length);

                    value.set(contents, 0, contents.length);
                } finally {
                    System.out.println("before close stream");
                    IOUtils.closeStream(in);
                }
                processed = true;
                return true;
            }
            System.out.println("out of processed");
            return false;
        }
  • 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-06-15T19:04:30+00:00Added an answer on June 15, 2026 at 7:04 pm

    java.io.InputStream.close is not blocking, at least API never says that. Compare
    InputStream.read

     Reads the next byte of data from the input stream. The value byte is
     returned as an <code>int</code> in the range <code>0</code> to
     <code>255</code>. If no byte is available because the end of the stream
     has been reached, the value <code>-1</code> is returned. This method
     blocks until input data is available, the end of the stream is detected,
     or an exception is thrown.
    

    and InputStream.close

      Closes this file input stream and releases any system resources
      associated with the stream.
    

    As for solving your problem I would suggest to use Java 7 Files.readAllBytes and forget about your puzzle.

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

Sidebar

Related Questions

My doubt is to skip a . from the input stream and read the
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.in(Standard input stream)- gets the input from keyboard
I am trying to read values from an input file in Perl. Input file
I want to read user input from STDIN and process the preliminary input while
I need to read some data from an input file and plot a graph
Is there any parameter that will read whole line from the input? I know
I'm writing a bash script in which I read single characters from the input.
Not parsing the parameters in the beginning but parse the input string read from
I want to read the file path from html input type=file (the entry selected
I wanna get all input from my pages timeline. so I read graph.facebook.com/pageid/feed with

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.