BufferedReader.readLine doesn't return null

Hi there,
I'm trying to put together a simple Chat client/server application. The issue I'm having is with the Server app. I have a class that extends Thread which contains this call:
temp = input.readLine()
in the run() method. Everytime I connect with the client side app, an instance of this class "ReceivingThread" is created and is supposed to read in any messages coming in using a BufferedReader. That's the input variable type. According to the API readLine() is supposed to return null when there's nothing more to read in. In my code I check for null but it never seems to leave the while loop.
Please advise,
Alan
package vcserver;
import java.io.*;
import java.net.*;
import java.util.StringTokenizer;
public class ReceivingThread extends Thread
  private BufferedReader input;
  private MessageListener messageListener;
  private boolean keepListening = true;
  public ReceivingThread(MessageListener listener, Socket clientSocket)
       super("ReceivingThread: " + clientSocket);
       messageListener = listener;
       try
            clientSocket.setSoTimeout(5000);
            input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
       catch(IOException ioe){ioe.printStackTrace();}
  public void run()
       StringBuffer messageBuffer = new StringBuffer();
       String temp = "";
       try
          START:
          while(keepListening)
             while(true)
                try
                              temp = input.readLine();
                catch(InterruptedIOException iioe)
                              continue;
                catch(IOException ioe){break;}
                   if(temp != null)
                try
                   System.out.println("temp: " + temp);
                   messageBuffer.append(temp);               
                 catch(Exception e)
                   e.printStackTrace();
                   break START;
                else
                break;
             System.out.println("out of while loop...message:\n" + messageBuffer.toString());
             String message = messageBuffer.toString();
             StringTokenizer tokenizer = new StringTokenizer(message, Constants.MESSAGE_SEPERATOR);
              if(tokenizer.countTokens() == 2)
          System.out.println("message received");
          messageListener.messageReceived(tokenizer.nextToken(), tokenizer.nextToken());
              else
          if(message.equalsIgnoreCase(Constants.MESSAGE_SEPERATOR + Constants.DISCONNECT_STRING))
          stopListening();
         input.close();
       catch(IOException ioe){ioe.printStackTrace();}
  public void stopListening()
       keepListening = false;
}Edited by: ashiers on Nov 20, 2007 10:51 AM

Not to mention garbage ...
readLine() returns null when there is nothing more to read, i.e. when the other end has closed its socket. If the other end hasn't closed its socket it won't return null, it will block. There might be more data coming later, at which time readLine() will unblock and read it and return it.

Similar Messages

  • BufferedReader  readLine() doesn't work?

    Hi! I was supprised when I saw that this code doesn't work.
    Can any help me, i want to read a html file?
    This is my code:
    String s="";
    BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(new File(newFile))));
    while (br.readLine()!=null)
    s=br.readLine();
    System.out.println(s);
    It doesn't read all lines!Some of them are missing.
    Thanks!

    I got this code from the file:
    log3: <!DOCTYPE NETSCAPE-Bookmark-file-1>
    log3: <!-- This is an automatically generated file.
    log3: It will be read and overwritten.
    log3: Do Not Edit! -->
    log3: <TITLE>Bookmarks</TITLE>
    log3: <H1>Bookmarks</H1>
    log3: <DL><p>
    log3: <DT><H3 FOLDED ADD_DATE="1111111111">Faks</H3>
    log3: <DL><p>
    log3: <DT><H3 FOLDED ADD_DATE="1111111111">neka</H3>
    log3: <DL><p>
    log3: <DT><H3 FOLDED ADD_DATE="1111111111">neka</H3>
    log3: <DL><p>
    log3: <DT><H3 FOLDED ADD_DATE="1111111111">neka</H3>
    log3: </DL><p>
    log3: </DL><p>
    log3: </DL><p>
    log3: <DL><p>
    log3: <DT>feri
    log3: </DL><p>
    log3: <DL><p>
    log3: <DT>Informatika
    log3: </DL><p>
    log3: </DL><p>
    log3: <DL><p>
    log3: <DT><H3 FOLDED ADD_DATE="1111111111">Tutorials</H3>
    log3: <DL><p>
    log3: <DT><H3 FOLDED ADD_DATE="1111111111">HTML</H3>
    log3: </DL><p>
    log3: <DL><p>
    log3: <DT><H3 FOLDED ADD_DATE="1111111111">JSP</H3>
    log3: </DL><p>
    log3: </DL><p>
    AND ORIGINAL IS:
    <!DOCTYPE NETSCAPE-Bookmark-file-1>
    <!-- This is an automatically generated file.
    It will be read and overwritten.
    Do Not Edit! -->
    <TITLE>Bookmarks</TITLE>
    <H1>Bookmarks</H1>
    <DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">Bookmarks</H3>
    <DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">Faks</H3>
    <DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">neka</H3>
    <DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">neka</H3>
    <DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">neka</H3>
    <DL><p>
    <DT>ales
    <DT>brr
    </DL><p>
    </DL><p>
    </DL><p>
    <DT>feri
    <DT>Informatika
    </DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">Tutorials</H3>
    <DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">HTML</H3>
    <DL><p>
    </DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">Java Server Pages</H3>
    <DL><p>
    </DL><p>
    <DT><H3 FOLDED ADD_DATE="1111111111">JavaScript</H3>
    <DL><p>
    </DL><p>
    </DL><p>
    <DT>Goggle
    <DT>Slo-tech
    </DL><p>

  • Possible bug: getPortletContext().getInitParameter() returns null

    Hi,
    Using config.getInitParameter("myParameter"); in GenericPortlet.init()
    doesn't return null.
    Using getInitParameter("myParameter"); in GenericPortlet.doView() doesn't
    return null.
    But using getPortletContext().getInitParameter("myParameter") does return
    null.
    (I did super in init)
    wlp 8.1 SP2
    Thank you for any and all help,
    Geoffrey

    My mistake. Thanks for clearing that up.
    Subbu, might you know if there are plans (and when it will be available if
    there are) to make it possible to import a protlet war file in Workshop and
    create insert the porlets from it in your portal without need to unjar &
    sort it into workshop?
    Thank you for any and all help,
    Geoffrey
    "Subbu Allamaraju" <[email protected]> schreef in bericht
    news:[email protected]..
    PortletConfig init params are different from PortletContext init params.
    PortletContext maintains context-wide init params whereas
    PortletConfig maintains portlet-specific init params.
    Subbu
    Geoffrey said the following on 01/05/2004 06:17 AM:
    Hi,
    Using config.getInitParameter("myParameter"); in GenericPortlet.init()
    doesn't return null.
    Using getInitParameter("myParameter"); in GenericPortlet.doView()
    doesn't
    return null.
    But using getPortletContext().getInitParameter("myParameter") doesreturn
    null.
    (I did super in init)
    wlp 8.1 SP2

  • BufferedReader readLine() not returning null

    I'm trying write an SMTP client using Socket.
    I'm sending EHLO command to the SMTP server is is returning multiline response. When I tried to read this multiline response using the BufferedReader in a while loop, it is never returning null.
    Following is my code snippet
    while(true)
                    data=reader.readLine();
                    multilineData +=data+"\r\n";
                    if(data==null )
                        break;
                    }why it is not returning?

    I have written debug statements.
    It is printing the following lines and it still expecting something from the server even though server has finished sending all the response.
    250-mail.merakdemo.com Hello <hostname>, pleased to meet you.
    250-ENHANCEDSTATUSCODES
    250-SIZE
    250-EXPN
    250-ETRN
    250-ATRN
    250-DSN
    250-CHECKPOINT
    250-8BITMIME
    250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
    250-AUTH=LOGIN
    250-STARTTLS
    250 HELP
    This is the end of response from server.
    And even I tried to break the while loop by checking the "HELP" String in the response. It is breaking the loop, but it is never returning the control.
    Following is the Code snippet:
    private String pullMultilineData(BufferedReader reader) throws CommunicationException
           String multilineData="";
           String data="";
            try
                while(true)
                    data=reader.readLine();
                    multilineData +=data+"\r\n";
                    // as per SMTP Protocol last line is without "-"
                    if(data==null || data.equals("") || data.indexOf("-")==-1)
                                        break;
                   logger.log(Level.DEBUG, "Data: "+data);
            catch(IOException ioe)
                logger.log(Level.ERROR, "I/O exception: "+ioe);
                throw new CommunicationException("unable to pull the respose, i/o error occured");
           return multilineData;
        }

  • Does readLine return null at end of file?

    My program is reading lines from a file in groups of 5. I want it to stop reading when it has reached the end of the file. Does readLine return null when there are no more lines or is there another way to end a loop like this?
    Thanks!
    try {
    String a, b, c, d, e;
    a = BR.readLine();
    b = BR.readLine();
    c = BR.readLine();
    d = BR.readLine();
    e = BR.readLine();
    while (a != null){
    a = BR.readLine();
    b = BR.readLine();
    c = BR.readLine();
    d = BR.readLine();
    e = BR.readLine();
    }                              

    readLine returns null at end of file. I actually use the following to end my loop...maybe this would help you.
    FileReader file = new FileReader("bkupcandilist.bin");
    BufferedReader buff = new BufferedReader(file);
    boolean eof = false;
    while(!eof) {     //retrieve all candidate names          
         scandi = buff.readLine();
         if(scandi == null) {
            eof = true;
         } else {
            atally = new String[2];
               atally[0] = scandi;
               atally[1] = "0";
               listtally.add(atally);
    buff.close();          

  • Why getAbsolutePath() doesn't return path?

    Hi, all:
    My code:
    public class Test {
    public static void main(String args[]) { 
    File aFile=new File("MustBeThere.doc");
    if (aFile.exists())
    String path=aFile.getAbsolutePath();
    else
    System.out.println("Null");
    It always return "Null". I assume to get a path instaed. I will be very grateful for any idea.
    Thanks
    Paul

    Hi,guys:
    I am pretty sure the file exitst. I found getAbsolutePath() only can find correct path if you pass the the whole path like:
    File aFile=new File("c:\something\test1.html");
    However, I'd like to pass "test1.html", then I expect returing sting is "c:\something\test1.html".
    Could you try the following code:
    import java.io.*;
    class FileInfo {     
         public static void main (String args[]) {          
              System.out.println("Enter file name: ");          
              String buf = "";
              try {               
                   BufferedReader bin = new BufferedReader(
                   new InputStreamReader( System.in ) );               
                   buf = bin.readLine();          
                   } catch (Exception e) {               
                        System.out.println("Error: " + e.toString());          
                        System.out.println( "File Name: " + buf.toString() );          
                        File file = new File(buf.toString());          
                        System.out.println( "File " + file);
                        if (file.exists()) {               
                             System.out.println("File Name : " + file.getName());               
                             System.out.println(" Path : " + file.getPath());               
                             System.out.println("Abs. Path : "+ file.getAbsolutePath());               
                             System.out.println("Writable : " + file.canWrite());               
                             System.out.println("Readable : " + file.canRead());               
                             System.out.println("Length : "+ (file.length() / 1024) + "KB");          
                             } else               
                             System.out.println("Sorry, file not found.");     
    Thanks in advance.
    Paul

  • FindNode returning Null And XML Not Accepting Special Characters

    Hi All,
    i am trying the get the attribute value in the element "ns4:InfoCFDi" using FindNode method, but the method is returning NULL. I used the same code for other sample as well and was successfull. but for this specific XML file(which is below) I am getting a Null.
    i can get till S:Body, but when i try to use FindNode for ":Body/s4:ResponseGeneraCFDi" I get Null value.
    And I used "S:Body/*[local-name()=" | "ns4:ResponseGeneraCFDi" | "]";
    as mentioned in other post but still no success.
    ==>I Have one more question relating to special characters. I need to use characters such as - ó in my XML to read as well as write. When I try to read i am getting XML parse error and when writing, i cannot open the file properly.
    Your help is much appreciated.
    My code is here:
    Local XmlDoc &inXMLDoc, &reqxmldoc;
    Local XmlNode &RecordNode;
    &inXMLDoc = CreateXmlDoc();
    &ret = &inXMLDoc.ParseXmlFromURL("D:\Agnel\Mexico Debit Memo\REALRESPONSE.xml");
    If &ret Then
    &RecordNode = &inXMLDoc.DocumentElement.FindNode("" );
    If &RecordNode.IsNull Then
    Warning MsgGet(0, 0, "Agnel FindNode not found.");
    rem MessageBox(0, "", 0, 0, "FindNode not found");
    Else
    &qrValue = &RecordNode.GetAttributeValue("asignaFolio ");
    Warning MsgGet(0, 0, "asignaFolio." | &qrValue);
    End-If;
    Else
    Warning MsgGet(0, 0, "Error. ParseXmlString");
    End-If;
    XML File:
    - <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    - <S:Body>
    - <ns4:ResponseGeneraCFDi xmlns="http://www.xxl.com/ns/xsd/bf/rxx/52" xmlns:ns2="http://www.sat.gob.mx/cfd/3" xmlns:ns3="http://www.xx/ns/bf/conector/1&quo t; xmlns:ns4="http://www.xx/ns/xsd/bfxx/xx/32&qu ot; xmlns:ns5="http://www.xxcom/ns/xsd/bf/xxxxx&q uot; xmlns:ns6="http://wwwxx.com/ns/referenceID/v1">
    - <ns3:Result version="1">
    <ns3:Message message="Proceso realizado con exito." code="0" />
    </ns3:Result>
    - <ns4:InfoCFDi noCertificadoSAT="20001000000100003992" refId="STORFAC20121022085611" fechaTimbrado="2012-10-22T08:56:45" qr=" "
    uuid="a37a7d92-a17e-49f4-8e4d-51c983587acb" version="3.2" tipo="XML" archivo="xxx" sello="B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=" fecha="2012-10-22T08:56:44" folio="281" serie="IICC">
    <InfoEspecial valor="Este documento es una representacin impresa de un CFDI." atributo="leyendaImpresion" />
    <InfoEspecial valor="||1.0|a37a7d92-a17e-49f4-8e4d-51c983587acb|2012-10-22T08:56:45|B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=|20001000000100003992||" atributo="cadenaOriginal" />
    <InfoEspecial valor="Doscientos dieciocho mil cuatrocientos setenta y cinco pesos 00/100 M.N." atributo="totalConLetra" />
    </ns4:InfoCFDi>
    </ns4:ResponseGeneraCFDi>
    </S:Body>
    </S:Envelope>
    TIA

    First of all you have to supply a value you want to search for and this has to be the complete path to the value. You're saying you already tried that, but can you paste the code which you used for that? I don't see the path mentioned in the code you posted.
    *FindNode*
    Syntax
    FindNode(Path)
    Description
    Use the FindNode method to return a reference to an XmlNode.
    The path is specified as the list of tag names, to the node that you want to find, each separated by a slash (/).
    Parameters
    Path
    Specify the tag names up to and including the name of the node that you want returned, starting with a slash and each separated by a slash (/). This is known as the XPath query language.>
    Another option would be this snippet of code:
    &InfoCFDiArray = GetElementsByTagName("ns4:InfoCFDi");
    &InfoCFDiNode = &InfoCFDiArray [1];
    &attValue = &InfoCFDiNode.GetAttributeValue("noCertificadoSAT")
    Warning(&attValue);
    It creates an array of XML Nodes which match the name "ns4:InfoCFDi". Since there's only one in the XML it's safe to assume it will be the one and only node in the array. I've assigned that node to the variable &InfoCFDiNode and use that to retrieve the attribute "noCertificadoSAT" value. The warning message should display the value supplied there.
    Concering the special characters; you will have to change the encoding of the XML. Peoplecode sets this to UTF-8 by default, but doesn't include this in the header. There's a little hack for that somewhere on the web, I'll see if I can find it.

  • Kff.where returns 'null'  and causes sql error - looking for a work around

    Hello,
    I am using BI 5.6.3 in EBS (11.5.10.2)
    I have created a kff.where as follows:
    <lexical
    type="oracle.apps.fnd.flex.kff.where"
    name="lp_location_where_clause"
    comment="Comment"
    application_short_name="OFA"
    id_flex_code="LOC#"
    id_flex_num=":lp_location_flex_structure"
    code_combination_table_alias="loc"
    segments="ALL"
    operator="BETWEEN"
    operand1=":p_location_low"
    operand2=":p_location_high"/>
    </lexicals>
    Everything works fine, as long as I have a values for the p_location_low and p_location_high. However, this is a parameter that comes in from a concurrent program and is optional. When the user doesn't pick a value, :p_location_low is the concatenated delimiters for the location '..'.
    When this runs, the kff.where is returning null which causes 'Invalid Relational Operation error' because 'AND null' is not valid.
    Warning in the log is :[091910_025232517][][STATEMENT] !!Warning: FlexAPI returns null for 'x_where_expression' lexical definition...
    Does anyone have a workaround for this since making the parameter required is not an option for my users?
    Thanks for reading.

    In your SQL*Plus session, make sure you
    SQL> set define offbefore trying to create the Java stored procedure. SQL*Plus assumes that any string that begins with an & is a substitution variable unless you tell it that you have no substitution variables (via set define off).
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • HelpSet.findHelpSet() returns null, and trapping ID errors

    I was having a problem initializing JavaHelp. HelpSet.findHelpSet() was returning null. I searched the forum, and found it was a common problem, but the answers were unhelpful. The answers pointed to a problem with CLASSPATH, but offered little in the way of advice for a newbie like myself on how to deal with it.
    A second issue concerns HelpBroker.enableHelpOnButton(). If you feed it a bogus ID, it throws an exception, and there's no way to trap it and fail gracefully. JHUG doesn't provide much in the way of alternatives.
    Now, having done a bit of research and testing, I'm willing to share a cookbook formula for what worked for me.
    I'm working in a project directory that contains MyApp.jar and the Help subdirectory, including Help/Help.hs. My first step is to copy jh.jar to the project directory.
    Next, in the manifest file used to generate MyApp.jar, I add the line:
        Class-Path: jh.jar Help/I'm working with Eclipse, so in Eclipse, I use Project - Properties - Java Build Path - Libraries to add JAR file jh.jar, and Class Folder Tony/Help
    I define the following convenience class:
    public class HelpAction extends AbstractAction
        private static HelpBroker helpBroker = null;
        private String label = null;
        public HelpAction( String name, String label )
            super( name );
            this.label = label;
        public void actionPerformed( ActionEvent event )
            displayHelp( label );
        public static boolean displayHelp( String label )
            if ( helpBroker == null )
                Utils.reportError( "Help package not initialized!" );
                return false;
            try
                helpBroker.setCurrentID( label );
                helpBroker.setDisplayed( true );
                return true;
            catch ( Exception e )
                Utils.reportError( e, "Help for " + label + " not found" );
                return false;
        public static boolean initialize( String hsName )
            URL hsURL = HelpSet.findHelpSet( null, hsName );
            if ( hsURL == null )
                Utils.reportError( "Can't find helpset " + hsName );
                return false;
            try
                HelpSet helpSet = new HelpSet( null, hsURL );
                helpBroker = helpSet.createHelpBroker();
            catch ( HelpSetException e )
                Utils.reportError( e, "Can't open helpset " + hsName );
                return false;
            return true;
    }If you use this class in your own code, you'll want to replace Utils.reportError() with something of your own devising.
    Finally, in my GUI class, I use the following:
        JPanel panel = ...
        JMenu menu = ...
        JToolbar toolbar = ...
        HelpAction.initialize( "Help.hs" )
        Action gsAction = new HelpAction( "Getting Started Guide", "gs.top" );
        menu.add( gsAction );
        JButton helpButton = new HelpAction( "Help", "man.top" );
        toolbar.add( helpButton );
        InputMap imap = panel.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
        imap.put( KeyStroke.getKeyStroke( "F1" ), "F1help" );
        ActionMap amap = panel.getActionMap();
        amap.put( "F1help", new HelpAction( null, "man.top" ) );

    Sorry, the sixth-from-last line of my example should read,
        JButton helpButton = new JButton( new HelpAction( "Help", "man.top" ) );

  • Why getResource of jar in classpath returns null?

    When i iterate through the jars in the classpath and try to turn them into URL's via the getResources(), they all return null. What am I doing wrong?
    (NOTE: It does print out the classpath properly when i print that out)
    String classPath = System.getProperty( "java.class.path" );
    String delim = System.getProperty( "path.separator" );
    String[] locations = classPath.split( delim );
    for ( int i = 0; i < locations.length; i++ )
          /* ** It doesn't work with either of these statments: ** */
          //This one tries the full path (e.g. /home/me/test/some.jar)
          //Enumeration en = getClass().getClassLoader().getResources( locations[ i ].substring( locations[ i ] );
          //This one tries to use just the local name of the jar (e.g. test.jar)
          Enumeration en = getClass().getClassLoader().getResources( locations[ i ].substring( locations[ i ].lastIndexOf( '/' ) + 1 ) );
          //This just prints null
          while (  en.hasMoreElements(); ) System.out.println( en.nextElement() );
    }Edited by: 6tr6tr on Dec 4, 2008 5:46 PM
    Edited by: 6tr6tr on Dec 4, 2008 5:47 PM

    What you are doing doesn't make sense. The resource locations within a JAR file are relative to the package directory structure within the JAR file, not to its own absolute location on the disk. And you seem to be expecting to retrieve a JAR file from within a JAR file. This makes no sense either.

  • Request.getCookies() returns null, not 0 length array

    (reposted from J2EE forum)
    Just upgraded to 9ias with Embedded OC4J and we were getting a NullPointerException.
    Our previous calls to request.getCookies() AKA http://java.sun.com/products/servlet/2.1/api/javax.servlet.http.HttpServletRequest.html#getCookies()
    would return an an array of Cookie Objects or an array of zero length if there are no cookies.
    When we upgraded to 9ias, we got the NPE.
    Know why?
    OC4J implementation of HttpServletRequest doesn't return a zero length array, it returns a null object when there are no cookies!!!
    So we had to change our code to catch this.
    Not a big problem, and it's fixed now, but it was a problem nonetheless.
    Any reason/rationale for why this was done this way? Anyone? Bueller?

    Josh,
    According to Servlet Spec 2.3 (page 193) SRV 15.1.3.2 Methods for (HttpServletRequest SRV.15.1.3) getCookies() returns null if no cookies present. So we are compliant to the spec.
    regards
    Debu Panda
    Oracle That's strange that the NPE problem didn't occurr until deleting cookies on OC4J, then.
    Thanks for responding!

  • A getName method allways returns null, why?

    I have an
    ArrayList<Animals> array_list = new ArrayList<Animals>();
    LinkedList<Animals> linked_list = new LinkedList<Animals>();
    I want the getName() method in class NewListener to be accessed from the class NextListener which extends NewListener, and therefor should get access to the method. But when I run the program, it allways returns null. Why?
    class NewListener implements ActionListener
              public String name;
              public void actionPerformed(ActionEvent e)
                   String str_name = showInputDialog(this,"Animal name: ",null);
                   if(str_name == null)
                        return;
                   for(int i=0; i<array_list.size(); i++)
                        if(array_list.get(i).getName().equalsIgnoreCase(str_name))
                             setName(str_name);                   // set the name with the setName() method
                             linked_list.add(array_list.get(i));
              public void setName(String name)
                   this.name=name;
              public String getName()
                   return name;        // this line returns "null"
                         // return "Hello";    // this line works and returns "Hello"
         class NextListener extends NewListener implements ActionListener
              public void actionPerformed(ActionEvent e)
                   try
                        linked_list .removeFirst();
                   }catch(NoSuchElementException er)
                        System.out.println("Numerical value");
                   String info =  getName()+" is in line";   // Why does the getName() method in the NewListener allways return a null?
                   showMessageDialog(this, info, "Notice", INFORMATION_MESSAGE);
         }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Roxxor wrote:
    Ok, I changed the name to private and I also tried with
    public void setName(String name)
    System.out.println("setting name on " + this + " to " + name); // <--- ADD THIS LINE
    this.name=name;
    }and it works. So this.name SHOULD get the value of name, but it doesn�t.
    So the question is: why does getName() return null?Your code is doing exactly what you're telling it to do. One or more of your assumptions is wrong. Keep digging. Add more print statements.
    Above all, you must drop the attitude that "it should work." There's a bug in your code. You have to find it. Repeating the mantra "It should work" is simply going to put blinders on and make it almost impossible to find your error. Instead, you have to think, "What did I do wrong?" and "If getName is returning null, then setName was never called or was called with null."

  • GetDocumentBase returns null in Update 40

    The change to make getCodeBase() and getDocumentBase() return null has broken our FindinSite-CD signed applet which is out in the field on many data CDs and similar, ie running locally.  It doesn't provide any more security as our all-permissions applet can still access the same information (once it knows where it is).  The trouble is, the CD may be run from anywhere so I do not know the absolute path in advance. I have found that I can add code so that JavaScript is used to pass the current URL as a PARAM to the APPLET.  However this should not be necessary.
    Can you provide a better fix that does not break all our existing users who update to Update 25 or 40?
    I would be happy for our applet to have access restricted to its own directory or lower.
    Or for an all-permissions applet, make getCodeBase() and getDocumentBase() return the correct values.
    Please see the second link below for a further discussion.
    Bug ID: JDK-8019177 getdocument base should behave the same as getcodebase for file applets
    Oracle's Java Security Clusterfuck
    PS  There is a separate Firefox 23 issue stopping access to local Java applets - this should be fixed this week in version 24.
    Chris Cant
    PHD Computer Consultants Ltd
    http://www.phdcc.com/fiscd/

    Our company uses the above FindinSite-CD software to provide search functionality on our data CDs and we have done so successfully for many years.  These latest changes in Update 40 have now broken this vital component on our product and will cost us considerably in technical support time and replacing the discs when a fix comes out. Just an end user's perspective!

  • SQL Query (PL/SQL Function Body returning SQL query) doesn't return any row

    I have a region with the following type:
    SQL Query (PL/SQL Function Body returning SQL query).
    In a search screen the users can enter different numbers, separated by an ENTER.
    I want to check these numbers by replacing the ENTER, which is CHR(13) || CHR(10) I believe, with commas. And then I can use it like this: POD IN (<<text>>).
    It's something like this:
    If (:P30_POD Is Not Null) Then
    v_where := v_where || v_condition || 'POD IN (''''''''||REPLACE(''' || :P30_POD || ''', CHR(13) || CHR(10), '','')||'''''''''')';
    v_condition := ' AND ';
    End If;
    But the query doesn't return any rows.
    I tried to reproduce it in Toad:
    select * from asx_worklistitem
    where
    POD IN (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    ==> This is the query that does't return any rows
    select (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    from dual;
    ==> This returns '541449200000171813','541449206006341366'
    select * from asx_worklistitem
    where pod in ('541449200000171813','541449206006341366');
    ==> and when I copy/paste this in the above query, it does return my rows.
    So why does my first query doesn't work?
    Doe anyone have any idea?
    Kind regards,
    Geert
    Message was edited by:
    Zorry

    Thanks for the help.
    I made it work, but via the following code:
    If (:P30_POD Is Not Null) Then
    v_pods := REPLACE(:P30_POD, CHR(13) || CHR(10));
    v_where := v_where || v_condition || 'POD IN (';
    v_counter := 1;
    WHILE (v_counter < LENGTH(v_pods)) LOOP
    v_pod := SUBSTR(v_pods, v_counter, 18);
    IF (v_counter <> 1) THEN
    v_where := v_where || ',';
    END IF;
    v_where := v_where || '''' || v_pod || '''';
    v_counter := v_counter + 18;
    END LOOP;
    v_where := v_where || ')';
    v_condition := ' AND ';
    End If;But now I want to make an update of all the records that correspond to this search criteria. I can give in a status via a dropdownlist and that I want to update all the records that correspond to one of these POD's with that status.
    For a region you can build an SQL query via PL/SQL, but for a process you only have a PL/SQL block. Is the only way to update all these records by making a loop and make an update for every POD that is specified.
    Because I think this will have a lot of overhead.
    I would like to make something like a multi row update in an updateable report, but I want to specify the status from somewhere else. Is this possible?

  • (DocumentBuilder).parse return null under jdk 1.5.0

    I would like to understand why the following code return a correct Document instance if it running under jdk 1.4.2 and instead return null if it running under jdk 1.5.0.
    Thanks!
    F.
    import java.io.IOException;
    import java.io.StringReader;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    String test = "<root>" + "" + "</root>";
    StringReader sreader = new StringReader (test);
    InputSource is = new InputSource(sreader);
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;
    builder = factory.newDocumentBuilder();
    Document doc =  builder.parse(is);
    System.out.println("Document is: " + doc);

    Because you're using the toString() method to display the Document. It works differently in Java 5 than it did in Java 1.4. This is perfectly okay because the DOM specification doesn't say anything about what the toString() method should return. If you relied on that for anything other than debugging then you were relying on an undocumented feature. Shouldn't do that.

Maybe you are looking for

  • Error in schema validation in XI. Please help!

    Hi Experts,    I have a FILE to proxy scenario. In the sender agreement I have selected schema validation by Adapter. (Other option is by Integration Engine). Now when the file I get an error in sender file communication channel monitoring: Error: co

  • All MonthNames and Month numbers in sql server

      Hi All, I want to display all months names and month numbers in a query.  like        MName               Mno January                1 February              2 March                   3             December           12 Regards, Mandava.

  • Solaris 10 - impressions from a GNU/Linux user

    Firstly, this isnt flame bait, honest! Until 10, I hadnt seen Solaris since rev6, then, I was worn (then) down by trying to configure a dial up model hacking chap scripts. Anyhow, I thought I'd look at Solaris 10, seeing as it was 'free' to play with

  • Mail or gmail? why should i switch?

    so i'm a recent switcher. i'm happy happy happy with the things about macos that enable much greater productivity and pleasure when interacting with my little macbook. so the reason to switch from PC to MAC is very clear. i can easily talk to others

  • Unable to view some things

    I just installed Mozilla Firefox and now I can't see everything on my FB page .. like the notification icons .. I can see the # if there a notification, but .. and also if I try to type lets say a smiley face :) .. it doesn't show it to me