473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

BufferedReader.read() blocks,when checking if there's any input for some URLs

1 New Member
Hi everyone ,

i have the following problem :
I am working on an application that index web pages. When i read the content of some URLs, BufferedReader.read() blocks, e.g. "http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid =29422575". All the alternatives that I've found have not solved this problem. This is my java code:
Expand|Select|Wrap|Line Numbers
  1.  public static void main(String[] args) throws Exception {
  2.         // TODO code application logic here
  3.         String _url = "http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=29422575";
  4.         BufferedReader reader = null;
  5.         try {
  6.             URL url = new URL(_url);
  7.             URLConnection urlConnection = url.openConnection();
  8.             reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
  9.             StringBuilder sb = new StringBuilder();
  10.             String line = null;
  11.  
  12.  
  13.  
  14.             while ((line = reader.readLine()) != null) {
  15.                 sb.append(line);
  16.                 sb.append("\n");
  17.                 System.out.println(line);
  18.             }
  19. //            System.out.println(sb.toString());
  20.         } catch (Exception ex) {
  21.             ex.printStackTrace();
  22.  
  23.         }
  24.  
  25.     }
  26.  
thanks a lot in advance , anyone...?
Mar 27 '12 #1
1 1584
r035198x
13,262 MVP
You can check id reading will block by calling BufferedReader.ready
Mar 28 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Lionel B | last post by:
I know this has probably come up frequently, but couldn't find a satisfactory reference... I have some code which needs to read from stdin but must not block waiting for input if there is no input...
3
by: MarsVoyager | last post by:
Hi, I want to change the value of a submit button when the onChange event is fired by a Radio Input. Problem is, it seems the value is modified in the gui only when the Radio Input looses focus,...
4
by: santa19992000 | last post by:
can I use scanf to get input (some times user enters input sometimes not, just hit keyboard)?. It displays to enter IP address, if user wants to change, then he enters, otherwise he hits keyboard,...
4
by: bill | last post by:
I am confused by the behavior of the following code. The function copy() takes two FILE *'s and copies the data from one to the other. In the main routine, I create a pipe and copy stdin to the...
3
by: Patrick Olurotimi Ige | last post by:
With the code below i get error:- Invalid attempt to read data when reader is closed. //Get a datareader SqlDataReader objDataReader; objDataReader =...
0
by: dolberg | last post by:
Hi, I have a Treeview containing groups and groupmembers and I would like to have the childnodes (groupmembers) checked when checking a parent node (a group). This is no problem using the...
2
by: Ben | last post by:
The following error is encountered when attempt to input the character > into a textbox control : A potentially dangerous Request.Form value was detected from the client Is there a way to...
5
by: angelotti | last post by:
Hi everyone , i have the following problem , i read data from another application that i started through the runtime.exec() in my Java class. I need to periodically check if there is any data...
2
by: Immature Little Child | last post by:
i've this question, when checking that input is numeric we use a_______, on my homework and if anyone can help that would be great.:)
2
by: =?Utf-8?B?S2lk?= | last post by:
Hi How can I control other process UI and input some data value like input edit box or click button controls ? Is there some good sample code and tool to help me ? Thank you .
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.