473,545 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ 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?fusea ction=user.view profile&fri endid=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 1589
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
3150
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 pending on stdin. I have some code which does the job (at least on my system... I wonder about the portability, though) but it's an ugly C hack; in...
3
1619
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, not when its value is changed by the user. How can I make the value on the submit button change immediately upon action on the radio input and...
4
3863
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, which should prompt next one, how can I do in C program?. Thanks. enter IP address:
4
7798
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 write end while copying the read end to stdout. If the child handles copying the read end of the pipe to stdout, the main program returns. If the...
3
3025
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 = objCommand.ExecuteReader(CommandBehavior.CloseConnection); datalistoutput.DataSource = objDataReader;
0
1745
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 TreeNodeCheckChanged-event. The problem is that a post-back is required to fire the event, and checking a checkbox in the Treeview doesn't cause a...
2
1080
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 resolve it? Thanks, Ben
5
6455
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 sent from it but when i try to BufferedReader.read() from the stream and the stream is empty the java app blocks ,supposably waiting for either the child...
2
970
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
1131
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
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7807
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7756
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4944
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1879
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 we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.