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

The Archive Base Latest Questions

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

I have a basic question for which I need a some clarification in it’s

  • 0

I have a basic question for which I need a some clarification in it’s use.
So if I have one class in Java say IOReadWrite.java, where I do some IO read/write. So that it may have an always connected loop something like:

while ((line = stream.readLine()) != null){
     //incoming data
}  

Now I have another class, call it FrontEnd.java where I am supposed to display the results coming in real time from IOReadWrite.java Class. Normally what is happening is that if I call the method of IO class, I can not get result unless the whole IO Operation is finished and I have to wait.

However what I want is to be able to get those results in real time, so that as soon as there is something on input Stream, I can get it in my FrontEnd Class to do whatever I want to do with it.

One idea I have come up with is using a static String variable in IOReadWrite.java and write a method which simply returns the value of this variable and I can poll this function from main class. But I’m pretty sure this is a very bad approach.

Can you suggest what is the proper way of getting such information in real time?

  • 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-28T03:22:46+00:00Added an answer on May 28, 2026 at 3:22 am

    You can do this

    FrontEnd frontEnd = 
    while ((line = stream.readLine()) != null){
         //incoming data
    
         // notify immediately.
         frontEnd.displayLine(line);
    }
    

    What displayLine does depends on your implementation of that class. Can you give any more details of that the class does with the information?

    Something it could do is

    private final BlockingQueue<String> linesQueue = ...
    
    public void displayLine(String line) {
         linesQueue.add(line);
    }
    
    // somewhere else, in another thread.
    String line = linesQueue.take(); // wait for a line.
    
    String line = linesQueue.poll(); // get the next or null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL question which may be basic to some but is confusing
It is a basic HTML question. I have some div tags, which have some
I have a basic PHP question, take the code below for example, let's say
Maybe a basic question but let us say I have a string that is
I am learning Java and have a pretty basic problem. I am indexing some
I have a website (the basic gist of which is described in this question
I have a some classes which I need to serialize in two different ways:
I have some basic questions about core data (which I am new to) and
I have a basic question, in the Django template language how can you tell
I have a basic question about assembly. Why do we bother doing arithmetic operations

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.