To find the error in java code if any

i was learnig java.net package and this is the code i wrote to read the contents directly from a given url using openStream() method of URL class and got the message 'error' from
java.io.IOException which i had given in the catch block. please tell me what is happening & how
could i read the content from an url with url class method.
import java.io.*;
import java.net.*;
public class url
public static void main(String[] args)
throws java.io.IOException,java.java.MalformedURLException
try{
URL yahoo = new URL("http://www.yahoo.com");
BufferedReader read_io = new BufferedReader(new InputStreamReader(yahoo.openStream()));
String line;
while((line =read_io.readLine())!= null)
System.out.println(line);
line.close();}
catch(MalformedURLException e)
System.out.println("error");
catch(IOException e)
System.out.println("error"):
after execution at the terminal
bash-3.00#javac url.java
bash-3.00#java url
error

Please use [code] tags when posting code.
Are you sure String has a close method? I'm not sure your code compiles.
Exceptions have a getMessage method, which can be useful (and a printStackTrace method that can be even more useful.)

Similar Messages

  • Please help in finding the error in this code

    Dear Friends,
    I am trying to make the value of 'Shift' on the basis of  BLDAT CPUDT & CPUTM of MKPF but I am doing something wrong. Kindly have a look at the following code, especially the IF..ELSEIF section and help me in finding the error.
    Regards,
    Alok.
    SELECT MBLNR MJAHR BKTXT BUDAT BLDAT CPUDT CPUTM USNAM
    INTO CORRESPONDING FIELDS OF TABLE I_MKPF1
    FROM MKPF
    WHERE
    BUDAT EQ S_BUDAT AND
    TCODE2 EQ 'MFBF'.
    ********************************************************ALOK 01.02.07
    LOOP AT I_MKPF1.
           I_MKPF-MBLNR = I_MKPF1-MBLNR.
           I_MKPF-MJAHR = I_MKPF1-MJAHR.
           I_MKPF-BKTXT = I_MKPF1-BKTXT.
           I_MKPF-BUDAT = I_MKPF1-BUDAT.
           I_MKPF-BLDAT = I_MKPF1-BLDAT.
           I_MKPF-CPUDT = I_MKPF1-CPUDT.
           I_MKPF-CPUTM = I_MKPF1-CPUTM.
           I_MKPF-USNAM = I_MKPF1-USNAM.
    IF   ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
    AND   ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'A'.
    ELSEIF ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
       AND  ( I_MKPF1-BLDAT <>  I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'C'.
    ELSEIF ( ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
      AND  ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'B'.
    ENDIF.
    APPEND I_MKPF.
    CLEAR I_MKPF.
    ENDLOOP.

    Hi.
    IF (  I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
           AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'A'.
    ELSEIF  ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
    AND ( I_MKPF1-BLDAT <> I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'C'.
    ELSEIF ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
    AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'B'.
    ENDIF.
    Try the above code ..
    Regards
    Sudheer

  • Please Find the error in this code

    Hi ,  I am new to ajax.My problem is that i cannot insert a value in to a textfield which is fetched from a database(MySql).  I have two jsp pages.Definition1.jsp and definition.jsp. I am giving the code below.[b]But it does not work[/b]. I don't know where is the problem. I am using Mozilla Firefox..  [b]Definition1.jsp[/b]  <html>  <%@ page language="java"%>  <%@page contentType="text/html" %>   <script language="Javascript" type="text/javascript">   function createRequestObject() { var tmpXmlHttpObject;   if (window.XMLHttpRequest) {   tmpXmlHttpObject = new XMLHttpRequest();       } else if (window.ActiveXObject) {   tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP"); }  return tmpXmlHttpObject; }  //call the above function to create the XMLHttpRequest object var http = createRequestObject();  function makeGetRequest(wordId) { //make a connection to the server ... specifying that you intend to make a GET request  //to the server. Specifiy the page name and the URL parameters to send http.open('get','definition.jsp?id='+wordId);       //assign a handler for the response http.onreadystatechange = processResponse;       //actually send the request to the server http.send(null); }  function processResponse() { //check if the response has been received from the server if(http.readyState == 4){       //read and assign the response from the server           var result2 = http.responseText;  var result = http.responseXML.documentElement;                  //do additional parsing of the response, if needed            //in this case simply assign the response to the contents of the <div> on the page.  document.getElementById('description').innerHTML = result2;//[b]this works correctly[/b]           alert(result.getElementByTagName('p')[0].childNodes[0].nodeValue);//nothing happends here            document.getElementById('name').value=result.getElementsByTagName('p')[0].childNodes[0].nodeValue;           [u][b]//above code does not works and this is my problem[/b][/b[/u]] } }   </script> <body>  <form> <input type="text" id="name" size=10 value=" "></input>  </form> <h1>Have you heard these terms before?</h1>  Ceraunophobia More about Ceraunophobia<br> Astraphobia More about Astraphobia<br>   <div id="description">  </div>  </body>  </html>     [b]Definition.jsp[/b]    <%@ page language="java"%><%@ page import="java.sql.*,java.io.*,java.util.*,javax.servlet.*"%> <?xml version="1.0" encoding="UTF-8"?>  <% response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("pragma","no-cache"); Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con=DriverManager.getConnection("jdbc:mysql://itserver:3306/manzor?user=root&password="); Statement st= con.createStatement(); Statement st1= con.createStatement();  ResultSet rs,rs1; String id=request.getParameter("id");  rs=st.executeQuery("select * from user where USERTYPE='"+id+"'");  if(rs.next()){    %>  // p tag is here , can't display it //<p> <p> <%=rs.getString(1)%></p>  //<p>  <%  }  %>[code]  [/code]  please help
    Message was edited by:
    manu_am
    Message was edited by:
    manu_am

    I'm not an AWT expert, but here's my best guess to the problem...
    I'm not sure that the ActionListener is the correct event listener to use here.
    I don't think the straight TextArea throws action events, I could be wrong here I mainly have experience with swing.
    What event are you trying to react to here? Also is there any reason for not using Swing? Then you can use the JTextArea.
    Hope I'm of some help :)

  • Not able to find the Error in code !

    please help me to find the error in my code. When I Added x1~kondm its not giving anything i.e
    *join t178t as x1
    *on   p1kondm = x1kondm
    in the SQL part !
    REPORT YINTERACTIVEPROGRAM01.
    TABLES:VBAP,
           VBPA,
           VBRP,
           VBRK,
           KNA1,
           ADRC,
           TPAR,
           TVKGG,
           TVM1T,
           TVM2T,
           TVM3T,
           TVM4T,
           VBKD,
           SZA1_D0100,
           T178T.
    TYPES:BEGIN OF TY_TAB,
             VBELN LIKE VBAK-VBELN,
             VKORG LIKE VBAK-VKORG,
             ERDAT LIKE VBAK-ERDAT,
             AUGRU LIKE VBAK-AUGRU,
             BSTDK LIKE VBKD-BSTDK,
             BSTDK_E LIKE VBKD-BSTDK_E,
             spart like vbap-spart,
             kondm like vbap-kondm,
             waerk like vbap-waerk,
             netwr like vbap-netwr,
             kwmeng like vbap-kwmeng,
             vkaus like vbap-vkaus,
             land1 like vbpa-land1,
             nrart like tpar-nrart,
           vtext like tpar-vtext,
             parvw like tpar-parvw,
             name1 like adrc-name1,
             name2 like adrc-name2,
             name3 like adrc-name3,
             name4 like adrc-name4,
             ort01 like kna1-ort01,
             pstlz like kna1-pstlz,
             vtext like t178t-vtext,
          END  OF TY_TAB.
    DATA: ITAB TYPE STANDARD TABLE OF TY_TAB WITH HEADER LINE.
    parameters:salesno like itab-vbeln.
    select s1~vbeln
           s1~vkorg
           s1~erdat
           s1~augru
           k1~BSTDK
           k1~BSTDK_E
           p1~spart
           p1~kondm
           p1~waerk
           p1~netwr
           p1~kwmeng
           p1~vkaus
           r1~land1
           t1~nrart
          t1~vtext
           t1~parvw
           n1~name1
           n1~name2
           n1~name3
           n1~name4
           c1~ort01
           c1~pstlz
           x1~vtext
    into corresponding fields of table itab
    from  vbak as s1
    join  VBKD as k1
    on   s1vbeln = k1VBELN
    join vbap as p1
    on   k1vbeln = p1vbeln
    *join t178t as x1
    *on   p1kondm = x1kondm
    join vbpa as r1
    on   p1vbeln = r1vbeln
    join tpar as t1
    on   r1parvw = t1parvw
    join ADRC as n1
    on   r1adrnr = n1addrnumber
    join kna1 as c1
    on   r1land1 = c1land1
    where k1vbeln = salesno and  s1vbeln = salesno and p1~vbeln = salesno
    and  r1~vbeln = salesno.
    loop AT ITAB.
      WRITE : /(30)'VBELN: ',  ITAB-VBELN,
              /(30)'VKORG: ',  ITAB-VKORG,
              /(30)'ERDAT: ',  ITAB-ERDAT,
              /(30)'AUGRU: ',  ITAB-AUGRU,
              /(30)'BSTDK: ',  ITAB-BSTDK,
              /(30)'BSTDK_E:', ITAB-BSTDK_E,
              /(30)'SPART: ',  itab-spart,
              /(30)'KONDM: ',  itab-kondm,
              /(30)'WAERK: ',  itab-waerk,
              /(18)'NETWR: ' , itab-netwr,
              /(18)'KWMENG: ', itab-kwmeng,
              /(10)'VKAUS:',   itab-vkaus,
              /(30)'LAND1:',   itab-land1,
              /(30)'NRART:',   itab-nrart,
              /(30)'PARVW:',   itab-parvw,
              /(30)'ADDR1:',   itab-name1,
              /(30)'ADDR2:',   itab-name2,
              /(30)'ADDR3:',   itab-name3,
              /(30)'ADDR4:',   itab-name4,
              /(30)'PSTLZ:',   itab-pstlz,
              /(30)'ORT01:',   itab-ort01,
              /(30)'Compiler desc:',   itab-vtext.
               uline.
    ENDLOOP.
                if sy-subrc <> 0.
                write : / 'No data found'.
                endif.

    hi,
      u failed to check relationship between tables and as well as mandatory fields need to be checked, i noticed following
    from vbak as s1
    join VBKD as k1
    on s1vbeln = k1VBELN
    join vbap as p1
    on k1vbeln = p1vbeln and k1posnr = p1posnr
    *join t178t as x1
    *on p1kondm = x1kondm
    join vbpa as r1
    on p1vbeln = r1vbeln   <b>and p1posnt = r1posnr </b> join tpar as t1
    on r1parvw = t1parvw
    join ADRC as n1
    on r1adrnr = n1addrnumber     <b> * No relation between these two tables/b]     
    join kna1 as c1
    on r1land1 = c1land1 <b>and r1kunnr = c1kunnr</b> <i>'here u need to check mandatory fields also</i>
    where k1vbeln = salesno and s1vbeln = salesno and p1~vbeln = salesno
    and r1~vbeln = salesno.
    anyway, in performance point of view, writeing code with this much joins is not acceptable.
    comeback if you need any further help
    regards,
    pavan
    Message was edited by:
            pavan kumar pisipati

  • How to track the information/error of java code while compiling.

    Hi,
    I want all the information or errors of java code during compilation.
    So that I can use this information or I can show these errors with different style.
    How to get the java syntax errors?

    Hi,
    I want all the information or errors of java code
    during compilation.
    So that I can use this information or I can show these
    errors with different style.
    How to get the java syntax errors?Redirect the STDOUT/STDERR from the the JAVA/JAVAC command to a file is one way...
    For instance at the commmand line:
    javac myClass.java > STDOUT.txt 2> STDERR.txt (Works for Unix variants or Windows OS's)
    Then you can do what ever you want with the data contained in the files.
    Hope this helps

  • Ipad2 shut off after down the battery but when connect the charger my ipad2 is not storing the power in the battery and i also not finding the error code ???

    ipad2 shut off after down the battery but when i connect the charger with my ipad2,  its not storing the power in the battery and i also not finding the error code ???

    If you drained the battery, it may take a bit for it to come back. I'd plug it in and leave it for a few hours and see if it's charging.
    If not, you can try to do a reset. Hold down the sleep and home keys for about 20 seconds. When you see the white apple, let go and let it reset and see if it charges.
    It's also possible that your battery has reached the end of its life. THey can only handle a finite amount of recharge cycles. If you can't get it to hold a charge, then make an appointment at your local apple store and explore your other options.

  • I have an issue installing photoshop CC trial, I currently have elements and wanted to see the differences before buying, when installing through the creative cloud app I get the error message  Exit Code: 7 Please see specific errors below for troubleshoo

    I have an issue installing photoshop CC trial, I currently have elements and wanted to see the differences before buying, when installing through the creative cloud app I get the error message  Exit Code: 7 Please see specific errors below for troubleshooting. For example,  ERROR: DW041 ...   -------------------------------------- Summary --------------------------------------   - 0 fatal error(s), 1 error(s)
    ERROR: DW041: INSTALLDIR Volume D:\ doesn't exist.  -------------------------------------------------------------------------------------  System Requirements  and it will not install, It says cant find the path D: im not sure why because as far as I can see its set to install on drive C: which is where I want it!

    Exit Code: 6, Exit Code: 7 Installation Errors - http://helpx.adobe.com/creative-suite/kb/errors-exit-code-6-exit.html
    Troubleshoot with install logs | CS5, CS5.5, CS6 - http://helpx.adobe.com/creative-suite/kb/troubleshoot-install-logs-cs5-cs5.html for information on how to review your installation logs

  • I upgraded from Dreamweaver CS4 to CS6. but now "an TFP error occured - cannot make connection to host". I spent hours with the host technician and we cant find the error. I reinstalled DW4 and it connects to host perfectly. Anyone else seen this problem?

    I upgraded from Dreamweaver CS4 to CS6. but now when I want to upload I get "an TFP error occured - cannot make connection to host". I spent hours with the host technician and we cant find the error. I reinstalled DW4 and it connects to host perfectly. Anyone else seen this problem?
    Mac OS 10.8.5
    None of these issues are causing the error in DW CS6. We have double checked all of them and we have everything exactly right. Also I have exactly the same SiteSetup in DW CS4 and that works perfectly well. Could there must be factor in 6 that didn't exist in 4? Something that isnt in the SiteSetup but in some hidden dialog box ?
    I can also upload to my host using Fetch, a third party FTP. And as I said DW CS4 works fine. So the problem is not with my host, its with DW CS6 in particular.

    Thank you Jon, that fixed it perfectly. You have saved me from going crazy. The only difference I see now is in "Server Name" it changed what I had entered (my ftp address) to "Remote Server"; which seems odd -- but it works!   Although I know there maybe also some other dialog box I have never seen
    Of course I saw that menu item "Import"  and but I thought thats obviously not for me: "Why would I want to import an entire website?". I did not however see "Export the selected site" for thats only a tiny icon in the footer. However I would have thought the same:  "Why would I want to export my entire website?".
    An observation: I've seen this problem in a lot of Adobe software, the menu-names of items are  obscure, non descriptive. What would be better would be for the menu names or popups to say "Export Site Setup settings" and "Import Site Setup settings"

  • Where can I find the relation between company code and plant?

    where can I find the relation between company code and plant?
    I need to the list of plants under a company code.
    Which table?

    yes,wayne weng   .What you said is right.
    Thank you very much!
    My MSN:[email protected]

  • Jdbc scenario .. where to find the error msg

    Hi,
    I am working on a scenario,
    abap proxy->jdbc adapter->MsSql server.
    Whle testing,
    i sent the payload xml from the sproxy test sceen.
    After that, i checked the "Monitor for processed xml messages" screen (SXI_MONITOR).
    There it shows the status "Processed successfully" for the message that i sent.
    But when i checked the sqlserver database, the record is not inserted.
    Where can i find, if anything gone wrong at Jdbc adapter, or there after.
    Thanks in advance,
    Ganesh

    Hi
    apart from this communication channel you can see the message in adapter engine
    to do this take the id of the message fromSXI_MONITOR
    then go to transaction sxmb_ifr
    inside this go to message  Monitoring
    under drop down select adapter engine and inside the window give the iD of your message which you have taken from MONI
    if you are not getting the filter for message ID then click on additional filter and give the iD
    after this you can see your message
    select the radio butten inside your message and click on details
    here you will get the log of each and every step which have been followed in processing the message and you can find the error exactly
    regards
    sandeep
    If helpful reward points

  • Any option is there to find the error record in loop for huge amount of rec

    Hi Guru's,
    In our production system we got a error. While debugging we found one of our loop getting 1 lakh records. One of the record from the internal table having some wrong values because of that its giving a error message. But we are not getting any proper message.
    Now our problem is its very difficult to debug all the records one by one. Even its not possible to give Watchpoint. bze in what situations its giving this error that also not predictable. So how to find the error record?
    Kindly suggest.
    Ananadhan

    Need a lot more info.
    To start with is this CR Designer or some other product?
    I suspect it's classic SAP products like Business One etc., if so please mark as answered and post your question int the correct forum.
    Thank you
    Don

  • I am set up mac mini and when I test the mail server by sending a mail from administrator to administrator I get the error message 'Diagnostic-Code: X-Postfix; connect to 127.0.0.1[127.0.0.1]:10024: Connection    refused'. Can any one suggest a solution

    I set up mac mini and when I test the mail server by sending a mail from administrator to administrator I get the error message 'Diagnostic-Code: X-Postfix; connect to 127.0.0.1[127.0.0.1]:10024: Connection    refused'. Can any one suggest a solution

    Thanks. Where could I possibly look for a firewall rule. I knowingly did not creat any. My system has internet coming to a Modem which then is connected to a wireless router. I have computers connecting to the router through cable as well as wireless. One of these computers has been our  mailserver using Mercury and Pegasus and that computer has a static IP address. The Mac Mini also has been assigned a different srtatic IP address. I have only set up user account, none of them an email account as I initially expect them to receive only internal mails. Is it necessary that I must set up an email id for each user while setting up the user account. My server id is server.local. So would the email id for local users be [email protected]?

  • What table where i can find the errors in Sales Order

    hi,
    what table where i can find the errors in Sales Order. here's my situations, I need to create a abap report of CRM sales order not replicated to R/3 and show what's the error. I can't find the actual error in CRMD_ORDDERADM_H and CRMD_ORDERADM_I. I also tried calling program "CRM_ORDER_READ" but the program doesn't display/returns error's on header and item level.
    please help.
    earl g. faren

    hi,
    what i need is a table where i can find the sales transaction errors. I'm doing a abap report to list down sales transactions with error(s). I checked the table CRMD_ORDERADM_H and CRMD_ORDERADM_I but there's no field for transaction errors.
    please help me find a table where I can link the tables above to get the specific errors for a sales transactions.
    thanks alot.

  • Got the error message ("Java(TM) Platform SE binary has stopped working")

    Hello Gurus,
    I installed java jdk1.6.0_24 in my laptop. After that i gave the command javac, i got the error message ("Java(TM) Platform SE binary has stopped working"). I willl highly appreciate any help on this.
    The OS on my laptop is Windows Vista Home Premium 64 bit.
    Thanks,
    Vish

    Vish,
    You may want to try one of the Java forums, as your question is specific to the JDK/JRE, and nothing to do with JDev/ADF. {forum:id=937} might be a good starting place.
    John

  • Please help me find the error in the annex VI,access

    Hello, everyone, this is a program about ACCESS, please help me find the error in the annex VI, why do I always run time error. Thank you very much.
    Attachments:
    write access test.vi ‏22 KB

    Thank you for your reply, I have an attachment process map, could you help me change it, I just want to put my number in the array can continue to update the database. And I want to create a table.
    this is my msn :[email protected]
    Waiting for your reply on line
    谢谢你的回复,我的附件中有程序图,能不能帮我改一下,我只是希望,把我的数组中的数能够持续的更新在数据库中。并且创建一个我想要的表。

Maybe you are looking for

  • ICal to-to syncing with iPad Calendar app.....

    Why is it still missing!?!??! I tried using the to-do feature in AppleMail and all I got on my .mac account on my iPad Mail was useless mime attachments...no way to edit or mark it completed. Also, who's ridiculous idea was it to migrate the to-dos f

  • Power consumption with dual power supply

    Hi, I need to know how dual power supply works, I mean, when you have two power supplies in a router if both of them are working at the same time, or if one of them is working while the other one only begin to work when the first one stops. And if bo

  • Can anyone explain why the generated URL of my BPS web app

    Errors as follows:- Business Server Page (BSP) error What happened? Calling the BSP page was terminated due to an error. SAP Note The following error text was processed in the system: Die URL enthält keine vollständige Domainangabe (cud015 statt cud0

  • VGA display not being detected

    My Mac mini often changes the display resolution when it wakes up from sleep, and I have to use the detect display command to get the correct resolution back. I just had to restart it because of a kernel panic event, and now it doesn't detect the dis

  • Weird Apple Universal Dock Problems

    I have had my Apple Universal Dock for about a year and a half.  I have many problems with it now.  I have an iPhone 3GS and I use my dock to charge it every night.  I have the apple remote (white). Problems: 1.Will not work with remote 2.Says iPhone