BufferedReader's readLine() method problem.

Hello,
If anyone can help me out I would not have to struggle :)
Here is the thing. I have a file like this:
1     srjetnuaazcebsqfbzerhxfbdfcbxyvihswlygzsfvjleengcftwvxcjriwdohjisnzppipiwpnniuiyjpeppaezftgjfviwxunu
2     ekjghqflatrcdteurofahxoiyvrwhvaxjgcuvkkpondsqhedxylxyjizflfbgusoizogbffgwnswohenjixwufcdlbjlkoqevqdy
3     stfhcbslgcrywwrgbsqdkcxfbizvniyookceonscwugixgrxvvkxiqezltsiwhhepqusjdlkhadvkzgiefgarenbxnxtxnqdqpfh
4     dcuefkdrkoovjwdrqbpgoirruutphuiobqweknxhboyktxzcczgekrlbfsbfuygjpheydiwaasxifphtldawxsfepotkgqqsivur
5     fpfrspbuhangkeugfuwexsgivetovkoyloddgofdcajwwlrocgjrhonsrfrfxozvgohwoytycfjoycrxdhnhxyitkeqynedrbroh
6     hgzqqsfgnotfepywbpccrosxborslqtkanyffrwknjapnzjnesjlkbbsckbyvgrxujqyocpcpctsqyzapcinhjyysxsdwfjugndr
7     pltzealtrklzrugxdcskndqyvsrzncitqvjcnndeqossyrifzvbqovtdzsixjlizsbxwutgqipuxfidxyoktwupsuqbqgnxdfbze
8     avpxfjgwpxnzfsfosgsryhpyaezigrqsxsgdvwdbwovhcchrijbitvbcvltrgvadogokaennwpjjpkuuttidlnqftdnzqpqafels
9     oyvztgletdwdtibshpzeuqryvulnubrqtgxwizfsdzqlgxvsebhslnovphgehfigbjyyqsirqcwflbnbnrflotpqytqzbgnkeyrk
10     unvryrnlqucuydrasyzyiclnjvospzdoviqchdhasxzffblwsewikzbznyegrqtjvxfxfjenvrboofbxfsynlxhyuvqprqbvoruk
and my java programs is like this:
public String searchForAString(String fileName, int lineNumber)
File fileObject = new File(fileName);
String finalString ="";
String record = "";
int line;
try
FileInputStream fileInputStreamObject = new FileInputStream(fileObject);
BufferedInputStream bufferedInputStreamObject = new BufferedInputStream(fileInputStreamObject);
//DataInputStream dataInputStreamObject = new DataInputStream(bufferedInputStreamObject);
BufferedReader bufferedReaderObject = new BufferedReader(new InputStreamReader(bufferedInputStreamObject));
//System.out.println(bufferedReaderObject.readLine());
//System.out.println("_____________________");
while((bufferedReaderObject.readLine()) != null)
System.out.println(bufferedReaderObject.readLine());
Last System.out.println statement only displays second, forth, sixth, eigth, tenth and null lines. Why not every line? Any ideas? Thanks!

You do relize that when you call the in.readLine()in
your loop conditional and in your loop body itreads
in diffrent lines. Try this:
public String searchForAString(String fileName,int
lineNumber)
File fileObject = new File(fileName);
String finalString ="";
String record = "";
int line;
try
FileInputStream fileInputStreamObject = new
FileInputStream(fileObject);
BufferedInputStream bufferedInputStreamObject =new
BufferedInputStream(fileInputStreamObject);
//DataInputStream dataInputStreamObject = new
DataInputStream(bufferedInputStreamObject);
BufferedReader bufferedReaderObject = new
BufferedReader(new
InputStreamReader(bufferedInputStreamObject));
//System.out.println(bufferedReaderObject.readLine());
//System.out.println("_____________________");
String s = bufferedReaderObject.readLine();
while(s != null)
System.out.println(bufferedReaderObject.readLine());
s = bufferedReaderObject.readLine();
Every time you call the readLine method, it doesread
a diffrent line. Java does not know you want toread
the same line twice.Err, shouldn't that be:
while(s != null)
System.out.println(s);
s = bufferedReaderObject.readLine();
Otherwise, you're still discarding a line if you use
two readLines in the while loop.yes you are correct... srry late last night and I wsa copying his code :).

Similar Messages

  • BufferedReader's readLine() method problem (REPOST)

    Hello,
    If anyone can help me out I would not have to struggle :)
    Here is the thing. I have a file like this:
    1 srjetnuaazcebsqfbzerhxfbdfcbxyvihswlygzsfvjleengcftwvxcjriwdohjisnzppipiwpnniui yjpeppaezftgjfviwxunu
    2 ekjghqflatrcdteurofahxoiyvrwhvaxjgcuvkkpondsqhedxylxyjizflfbgusoizogbffgwnswohe njixwufcdlbjlkoqevqdy
    3 stfhcbslgcrywwrgbsqdkcxfbizvniyookceonscwugixgrxvvkxiqezltsiwhhepqusjdlkhadvkzg iefgarenbxnxtxnqdqpfh
    4 dcuefkdrkoovjwdrqbpgoirruutphuiobqweknxhboyktxzcczgekrlbfsbfuygjpheydiwaasxifph tldawxsfepotkgqqsivur
    5 fpfrspbuhangkeugfuwexsgivetovkoyloddgofdcajwwlrocgjrhonsrfrfxozvgohwoytycfjoycr xdhnhxyitkeqynedrbroh
    6 hgzqqsfgnotfepywbpccrosxborslqtkanyffrwknjapnzjnesjlkbbsckbyvgrxujqyocpcpctsqyz apcinhjyysxsdwfjugndr
    7 pltzealtrklzrugxdcskndqyvsrzncitqvjcnndeqossyrifzvbqovtdzsixjlizsbxwutgqipuxfid xyoktwupsuqbqgnxdfbze
    8 avpxfjgwpxnzfsfosgsryhpyaezigrqsxsgdvwdbwovhcchrijbitvbcvltrgvadogokaennwpjjpku uttidlnqftdnzqpqafels
    9 oyvztgletdwdtibshpzeuqryvulnubrqtgxwizfsdzqlgxvsebhslnovphgehfigbjyyqsirqcwflbn bnrflotpqytqzbgnkeyrk
    10 unvryrnlqucuydrasyzyiclnjvospzdoviqchdhasxzffblwsewikzbznyegrqtjvxfxfjenvrboofb xfsynlxhyuvqprqbvoruk
    and my java programs is like this:
    public String searchForAString(String fileName, int lineNumber)
    File fileObject = new File(fileName);
    String finalString ="";
    String record = "";
    int line;
    try
    FileInputStream fileInputStreamObject = new FileInputStream(fileObject);
    BufferedInputStream bufferedInputStreamObject = new BufferedInputStream(fileInputStreamObject);
    //DataInputStream dataInputStreamObject = new DataInputStream(bufferedInputStreamObject);
    BufferedReader bufferedReaderObject = new BufferedReader(new InputStreamReader(bufferedInputStreamObject));
    //System.out.println(bufferedReaderObject.readLine());
    //System.out.println("_____________________");
    while((bufferedReaderObject.readLine()) != null)
    System.out.println(bufferedReaderObject.readLine());
    Last System.out.println statement only displays second, forth, sixth, eigth, tenth and null lines. Why not every line? Any ideas? Thanks!
    Re: BufferedReader's readLine() method problem.
    Author: EagleEye101 Feb 18, 2005 8:48 PM (reply 1 of 1)
    You do relize that when you call the in.readLine() in your loop conditional and in your loop body it reads in diffrent lines. Try this:
    public String searchForAString(String fileName, int lineNumber)
    File fileObject = new File(fileName);
    String finalString ="";
    String record = "";
    int line;
    try
    FileInputStream fileInputStreamObject = new FileInputStream(fileObject);
    BufferedInputStream bufferedInputStreamObject = new BufferedInputStream(fileInputStreamObject);
    //DataInputStream dataInputStreamObject = new DataInputStream(bufferedInputStreamObject);
    BufferedReader bufferedReaderObject = new BufferedReader(new InputStreamReader(bufferedInputStreamObject));
    //System.out.println(bufferedReaderObject.readLine());
    //System.out.println("_____________________");
    String s = bufferedReaderObject.readLine();
    while(s != null)
    System.out.println(bufferedReaderObject.readLine());
    s = bufferedReaderObject.readLine();
    Every time you call the readLine method, it does read a diffrent line. Java does not know you want to read the same line twice.
    Tried it, did not work. I need to go through each line of the file I have. Any ideas?

    solution should be in your other thread.
    Please do not repeat threads--it really bugs the people here, just some 'nettiquite' --I don't mean to be a grouch.
    --later.  : )                                                                                                                                                                                                                                                                                                                                                       

  • BufferedReader's readLine() method

    i use this readLine() method to read from a file.
    in this file, there is only a line of normal text, say "hello".
    after saving the returned String from readLine() method,
    i find that it is not as same as "hello" anymore -> i get a
    false while comparing the two strings : one is the derived string from bufferedreader's readLine() method, another one is from a string variable i defined in the program.
    what is wrong here ?

    hi ya abnormal !
    below is the piece of code of mine :
    =====================================               FileReader bf = new FileReader("test.txt");
                   BufferedReader br = new BufferedReader(bf);
                   br.readLine();
                   String s1 = br.readLine();
                   String s2 = "hihi";
                   char[] c1 = s1.toCharArray();
                   char[] c2 = s2.toCharArray();
                   System.out.println("String 1: ");
                   for (int x = 0; x < c1.length; x++)
                   {  System.out.print((int)c1[x]+" ");}
                   System.out.println();System.out.println("String 2: ");
                   for (int x = 0; x < c2.length; x++)
                   {  System.out.print((int)c2[x]+" ");}
                   System.out.println();               
                   boolean result = false;
                   if (s1 == s2)
                   result=true;
                   System.out.println(result);
                   br.close();
                   bf.close();
    =============================
    i get a false :(
    from your piece, the output integers representing the two strings are equal. but not after the comparison...
    of course , the first line in the file test.txt is "hihi".
    i even tried to move the "hihi" to the 2nd line out of 3 lines in the test.txt file, to avoid EOF or \r\n , if there are... the result is the same. false ....
    what could be wrong ?

  • Writing my own readLine() method

    I am trying to write my own readLine() method. I am using the read() method from BufferedReader to read one char at a time into an array. Then when I encounter a \n chacter I convert the array to a string and return it.
    The problem arrises when i reach the end of a file.
    The read() method returns a -1 when the end of the file has been reached.
    How can I get my readline method to read the last line and return it but also tell the user the end of the file has been reached?
    Thanks.

    The reason I want to write my own is beacause
    readLine() in BufferedReader has been deprecated.
    No it isn't. Not until 1.3.1, at least.
    I want to read and return lines until read() returns a
    -1. But how can i still return the last line? err... with a return statement?
    It may contain a string and then be the end of the file. How
    can I return the string and the -1?You can't. You'll have to do it the way readLine already does or really think of something new.

  • How to use the readLine()  method when reading data from a URL?

    Hello,
    I have a URL which contains text input.
    The only way to get the data from this URL is by opening a URL connection to it.
    I would like to get the data from this URL but at the same time I would like to be able to use readLine() method of BufferedReader in order to read the data line by line.
    My question is how do I combine between these two requirements in order to reed the data from the URL?
    Roy

    Hello Roy,
    can you try out this code.
      URL yahoo = new URL("http://www.yahoo.com/");
            URLConnection yc = yahoo.openConnection();
            BufferedReader in = new BufferedReader(
                                    new InputStreamReader(
                                    yc.getInputStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null)
                System.out.println(inputLine);
            in.close();
    Regards,
    Mohan R

  • I need a solution for the deprecated readLine() method .

    import java.io.*;
    import java.net.*;
    class UC {
    public static void main(String args[]) throws Exception
    DataInputStream inFromUser = new DataInputStream(System.in);
    DatagramSocket clientSocket = new DatagramSocket();
    InetAddress IPAddress = InetAddress.getByName("hostname");
    byte[] sendData = new byte[1024];
    byte[] receiveData = new byte[1024];
    while(true)
    String[] sentence = inFromUser.readLine(); /* It says the readLine() method is deprecated. what is the solution for this? */
              sentence.getSubstringBytes(sentence,0, sentence.length(), sendData, 0);
    //sentence.getBytes(0, sentence.length(), sendData, 0);
    DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876);
    clientSocket.send(sendPacket);
    DatagramPacket receivePacket
    = new DatagramPacket(receiveData, receiveData.length);
    clientSocket.receive(receivePacket);
    String modifiedSentence =
    new String(receivePacket.getData());
    System.out.println("FROM SERVER:" + modifiedSentence);
         public void getSubstringBytes(String sentence,int space,int Size,byte[] sendData,int space)
                   byte[] bytes=sentence.getBytes();
                   System.arraycopy(bytes,0,sendData,0,sentence.length()-0);
    }

    Sorry, It should be the BufferedReader , not BufferedInputStream.

  • URGENT!! - Bug on read (readLine) method?

    Hello to all, I have need of a large aid.
    I need to know if There is the possibility that the method read() or readLine(), than I use for reading data from a socket from a PLC, has a Bug.
    This why, with the socket opened and of the data in arrival from the PLC (than does not give to errors), the method read() raises the "Connection exception reset by peer."
    The Technicians of the PLC say not to have errors but and I am surest of the correct operation of the server socket, also why it has been tested with telnet, hyperterminaly and others client without problems.
    I do not know that what to say and what to try.
    Thanks for every eventual aid.

    I don't think there is a bug with BufferedReader. But instead of using buffered reader, you can try using the socket input stream directly for reading to see if it makes any difference:
    try {
      // if the PLC is a client:
      ServerSocket serverSocket = new ServerSocket(...);
      Socket socket = serverSocket.accept();
      // or if the PLC is a server:
      Socket socket = new Socket(...);
      // and the rest of the code to test with
      InputStream in = socket.getInputStream();
      byte[] buffer = new byte[1024];
      int length;
      while ((length = in.read(buffer)) != -1) {
        System.out.println("Read "+length+" bytes");
      System.out.println("Connection closed");
    } catch (Exception e) {
      e.printStackTrace();
    }See if that little example works.
    Is the PLC i client or server? Is the PLC the first to write something to your java program or do you have to write something to it first (maybe it doesn't understand what you write to it).
    If you use reader/writer classes, there could be problems with the character encoding you use. If you don't specify any with InputStreamReader/OutputStreamWriter, then you will use the default platform encoding. I don't know which character encoding the PLC use, but if the characters are between 0 and 255, and you really want to use reader and writer classes, then use the ISO 8859-1 encoding.

  • Using Calendar.set() method problem

    Hi all,
    First of all sorry to bother with such a trivial(?) matter but I cannot solve it by myself.
    I have a piece of code which I simply want to handle the current date with the GregorianCalendar object so that the date would be set to the Calendar.SUNDAY (of the current week). Simple enough?
    Code as follows:
    import java.util.*;
    import java.text.*;
    public class Foo
    public static void main(String[] args)
         Foo foo = new Foo();
         Date newdate = foo.bar();
    public Date bar()
         GregorianCalendar m_calendar = new GregorianCalendar(new Locale("fi","FI"));
         m_calendar.setFirstDayOfWeek(Calendar.MONDAY);
         Date newDate = null;
         try
              m_calendar.setTime(new Date());
              System.out.println("Calendar='" + m_calendar.toString() + "'");
              m_calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
              StringBuffer sb = new StringBuffer();
              sdf.format(m_calendar.getTime(), sb, new FieldPosition(0));
              System.out.println("Date in format (" + sdf.toPattern()          + ") = '" + sb.toString() + "'");
         catch(Exception e)
              e.printStackTrace();
         return m_calendar.getTime();
    This should work at least accoring to my understanding of the SDK documentation as follows with
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
    Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
    Calendar='java.util.GregorianCalendar[time=1054636838494,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Helsinki",offset=7200000,dstSavings=3600000,useDaylight=true,transitions=118,lastRule=java.util.SimpleTimeZone[id=Europe/Helsinki,offset=7200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2003,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=1,DAY_OF_MONTH=3,DAY_OF_YEAR=154,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=40,SECOND=38,MILLISECOND=494,ZONE_OFFSET=7200000,DST_OFFSET=3600000]'
    Date in format (yyyy.MM.dd) = '2003.06.08'
    Which is the sunday of this week. But as I run the same code with:
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1.06-020625-14:20)
    Java HotSpot(TM) Server VM (build 1.3.1 1.3.1.06-JPSE_1.3.1.06_20020625 PA2.0, mixed mode)
    Calendar='java.util.GregorianCalendar[time=1054636630703,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=java.util.SimpleTimeZone[id=Europe/Helsinki,offset=7200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2003,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=1,DAY_OF_MONTH=3,DAY_OF_YEAR=154,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=37,SECOND=10,MILLISECOND=703,ZONE_OFFSET=7200000,DST_OFFSET=3600000]'
    Date in format (yyyy.MM.dd) = '2003.06.01'
    Which is sunday of the previous week and incorrect in my opinion. The latter result is run on HP-UX B.11.11 U 9000/800 and first on NT.
    Any ideas why this is happening? Thanks in advance!
    Greets, Janne

    Thanks for your answer!
    The problem is that I have to work with this older SDK version. :) But I got it solved by using the roll method with the following syntax:
    int delta = [dayToSet] - m_calendar.get(Calendar.DAY_OF_WEEK);
    in which the delta is of course the difference (negative or positive to the current day of the week)
    and then using the roll call:
    m_calendar.roll(Calendar.DAY_OF_WEEK, delta);
    which doesn't alter the current week. So this works if someone else has a similar problem with the version 1.3.1
    Greets, Janne

  • Enhance Method Problem

    I try to enhance a Method like described in this Thread...
    Re: Sending Email using the Outlook Client
    What I did so far...
    1) In Transaction "bsp_WD_CMPWB"  I choosed Component "BP_ADDR" and created a copy in our "Z_CRM" EnhancementSet
    2) I used the right Mousebutton to Enhance the "BP_ADDR/StandardAddress" View
    Two things had been automatically generated/created...
    - Table Contents BSPWD_CMP_C_REPL
    - Object ZL_BP_ADDR_STANDARDADDRES_CTXT
    3) I doubleclick on the enhanced View "BP_ADDR/StandardAddress"
        (-> In the "View Layout" node the StandardAddress.html is still using the Super Classes / Implementation Class CL_BP_ADDR_STANDARDADDRES_CN01 )
    4) If I go to Implemetation Class CL_BP_ADDR_STANDARDADDRESS_CN01
    5) Select method "GET_P_E_MAILSMT" (and look into the coding)
       The enhancement Functions there are not working for meu2026
       I tried the Button with the (Sprial / helix)
       and the Menu "Edit"-> "Enhancement Operations"
    Where is my error?! (I think I have to create a ZClass for the CL_BP_ADDR_STANDARDADDRES_CN01?!?!? But how to???)
    I will give all possible points for good answers
    Thanks for helpingu2026

    hi,
    Some times I also faced problems to create Zclass for standard ones. But you can do one trick to create Zclass.
    Try to create one dummy attribute in your context node, then it will creates  automatically Zclass for that node. Later you can delete that attribute.
    If you get any problems to create P-getter method, then copy the IF_BSP_WD_MODEL_SETTER_GETTER~_GET_P_XYZ template method and rename to GET_P_E_MAILSMT.
    regards
    Ismail

  • Multiple Payment Methods problem in F110 - Parameters

    <b>Prob : Wehn I enter more than one payment method in Parameters in F110 only the 1st Payment method entered is saved. The other payment method gets deleted automatically.</b>
    Following is already done :
    1. All the payment methods entered in F110 Parameters is already maintained in
    the vendor master.
    2. In FBZP - Payment Method for Country & Payment Method for Company Code
    is configured for all the payment methods.
    3. Also Invoices in FI (FB60) are posted for all the payment methods without any
    errors.
    4. Ranking order is maintained for each payment method & for the house bank
    used.
    5. Account determination is also maintained for all the payment methods for the
    respective house bank.
    6. The maximum amount is also maintained for all the payment methods under "Payment Methods for Comapany Code".
    Pl help to resolve this problem.

    hi,
    My problem is in the parameter stage 1st Screen.
    Also you cannot assign more than one Payment Method in the Print Variant.
    Also this variant is used only for printing. Its not called at the stage when I am entering the Payment Method in the 1st screen in the Parameter.
    I have somewhat found out what the problem is.
    I guess there is some change done in the standard SAP program, becuase if i type more than one payment method in the Parameter 1st screen and try to save it, it returns with a warning message "Only one Payment Method can be entered". This is a unique msg which has been written through a Z Program.
    Thanks.
    Bye.

  • PaintComponent method problems...

    Hi, I am developing an game application ( just for fun ) and I have a huge problem with paintComponent method. I Have a class ImagePanel that extends JPanel class. The ImagePanel class overrides the paintComponent method and paintChildren method ( since i have added components inside the JPanel also these must be painted ). The ImagePanel is instantied in my main class IntroView which extends JFrame where it's added. Now when the IntroPanel is created i have noticed that the paintComponent and paintChildren method is called all over again . I Have a soundclip playing in background in it's own thread and this continously paintComponent method call causes the sound clip to break off in few seconds. I Have tried to use JLabel instead of JPanel, but then the image is not shown( alltougth the methods are called only once ). I Have also tried next code to get rid of continous paintComponent call
    ...from ImagePanel class
    ImagePanel extends JPanel.....
    public final void paintComponent( Graphics g )
    if( firstTime )
    super.paintComponent( g );
    g.drawImage( myImage, 0, 0, this );
    firstTime = false;
    public final void paintChildrens( Graphics g )
    if( paintChildren )
    super.paintChildren( g );
    add( startLabel );
    add( optionsLabel );
    paintChildren = false;
    public boolean isOpaque()
    return true;
    Now the paintComponent and paintChildren is called only once. There is still a "little problem" since the paintComponent doesen't paint the image, it paints only the background( I think g.drawImage(...) didint have time to paint the image? ). Also the labels added in paintChildren method are not shown. Sounds paly now just fine.This situation makes me grazy. Please consult me with this problem.....i can surely send also the whole source if needed. There is no effect if I change isOpaque to true or false.

    Hi,
    Thanks for advices, I solved the problem...it was simplier than i thought. When the g.drawImage(.... is called ) i just added Thread.sleep( time ) after that line. This gives the sound therad time to play the sound without interrput and time to main thread to handle the image. All works now pretty much as i thought, except when JFrame is overlapped the image is not drawn again...this can be corrected ( maybe?)by adding windoslistener and implement the methods in that inteface and make some repainting in different situations. But cause you gave me the magic work Thread priority I hox! the problem, so here goes 10 duke dollars.

  • APPLET'S STOP METHOD - PROBLEM!!

    I'm learning java on my own, and I have a problem. Could you help me.
    The stop()** method in my applet does not show on the appletviewer until I close the appletviewer.
    I open another program like notepad, but when I come back to the appletviewer it doesen't show!
    It only shows right before I close it.
    Why is that?
    Thanks
    stop() {
    showStatus("STOPPED");

    Dear JustAnotherProgramer,
    pillaged from the docs
    stop
    public void stop()
    Called by the browser or applet viewer to inform this applet that it should stop its execution. It is called when the Web page that contains this applet has been replaced by another page, and also just before the applet is to be destroyed.
    It seems that if you run it in a browser and you go to the other page(same browser) it will be called.
    I guess by changing focus between different application(notepad) it will not work.
    Thank
    Joey

  • ActiveX Server Method Problem

    LabView men help me!
    I have a problem with using ActiveX Server Method object.Run(async) with
    async = TRUE in MS Visual C++ program.
    I want to call ActiveX Server and continue program execution.
    I call this metod in program block.
    COleVariant No_Wait;
    No_Wait.boolVal = TRUE;
    pVI->Run(No_Wait);
    After this operator I can not return from VI, until VI does not close, inspite
    of parameter async = TRUE.
    I ask your send me example how to use this metod and wait for you recomendations.
    Gregory.

    I think I have exactly the example program both of you are looking for. Take a look and post to let us know if you have any questions. Thanks!
    Best Regards,
    Chris C
    Applications Engineering
    National Instruments
    Chris Cilino
    National Instruments
    LabVIEW Product Marketing Manager
    Certified LabVIEW Architect
    Attachments:
    Calling_LabVIEW_from_C++_Using_ActiveX.zip ‏4972 KB

  • Finder methods problem

    Hi
    I met a very funny problem. when I try to deploy a entity BMP.(compile was ok).
    The bean have a method called findSubElements(this is not a finder method). I
    got the a exception:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ ejbFindXXX method
    for 'findSubElements(java.lang.String,jav
    a.lang.String,java.lang.String)' not found on class 'entity.XXXEntityBean_sgz73u_Impl'.
    what should I do to fix that ?
    Thanks for help.

    Hi
    It's working on WLS6.0 SP2 very well.
    Macsym
    PenFriend <[email protected]> wrote:
    Macsym,
    this isa known issue Cr06867. As a workaround chamge the name of the
    methods to not start with
    a find.
    macsym wrote:
    I've tried to re-run it. In my
    classpath=.;.\lib\weblogic_sp.jar;.\lib\weblogic.jar;
    but the problem still here. I'v just changed examples under WLS totest it.
    BTW I using WLS6.1 SP1.
    Thanks any way.
    Macsym
    Rob Woollen <rob@trebor_nelloow.moc> wrote:
    It looks like you need to re-run weblogic.ejbc. Also make sure that
    your classes are only
    in the ejb-jar file and not the server's classpath.
    Finally, what version of WLS are you using? It shouldn't be throwing
    an AssertionError for
    this.
    -- Rob
    macsym wrote:
    Hi
    I met a very funny problem. when I try to deploy a entity BMP.(compilewas ok).
    The bean have a method called findSubElements(this is not a findermethod). I
    got the a exception:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ ejbFindXXXmethod
    for 'findSubElements(java.lang.String,jav
    a.lang.String,java.lang.String)' not found on class 'entity.XXXEntityBean_sgz73u_Impl'.
    what should I do to fix that ?
    Thanks for help.

  • Edit method problem???

    Hi,forgive for all the code but i've asked this question before and people asked for more code.The problem is i get an error in publicationmain saying "undefined varible newpublication" so how do i fix this?and is my edit method goin to work?using the get and set method?can u show me how do do this please?feel free to make any other changes.thanxs a reply would be most heplful
    public class publication
    public int PublicationID;
    public String publicationname;
    public String publisher;
    public String PricePerIssue;
    public String pubstatus;
    public String publicationtype;
    public publication(int NewPublicationID, String Newpublicationname, String Newpublisher, String NewPricePerIssue, String Newpubstatus, String Newpublicationtype)
    PublicationID = NewPublicationID;
    publicationname = Newpublicationname;
    publisher = Newpublisher;
    PricePerIssue = NewPricePerIssue;
    pubstatus = Newpubstatus;
    publicationtype = Newpublicationtype;
    public String toString ()
    String pubreport = "---------------------------Publication-Information-----------------------------";
    pubreport += "Publication ID:" PublicationID"/n";
    pubreport += " Publication Title:" publicationname"/n";
    pubreport += " publisher: " publisher"/n";
    pubreport += " price Per Issue: " PricePerIssue"/n";
    pubreport += " publication Status: " pubstatus"/n";
    pubreport += " publication Type: " publicationtype"/n";
    return pubreport;
    public void SetPublicationID(int PubID)
    PublicationID = PubID;
    public int GetPublicationID()
    return PublicationID;
    public void Setpublicationname(String pubname)
    publicationname = pubname;
    public String Getpublicationname()
    return publicationname;
    public void Setpublisher(String Pub)
    publisher = Pub;
    public String Getpublisher()
    return publisher;
    public void SetPricePerIssue(String PPI)
    PricePerIssue = PPI;
    public String GetPricePerIssue()
    return PricePerIssue;
    public void Setpubstatus(String Status)
    pubstatus = Status;
    public String Getpubstatus()
    return pubstatus;
    public void Setpublicationtype(String Pubtype)
    publicationtype = Pubtype;
    public String Getpublicationtype()
    return publicationtype;
    import java.util.*;
    import publication;
    public class PublicationContainer
    LinkedList PubList;
    public PublicationContainer()
    PubList = new LinkedList();
    public int add (publication newpublication)
    PubList.addLast(newpublication);
    return PubList.size();
    private class PubNode
    public publication pubrecord;
    public PubNode next;
    public PubNode (publication thepublicationrecord)
    publication p = thepublicationrecord;
    next = null;
    public String toString()
    return PubList.toString();
    public void remove(int PubID)
    PubList.remove(PubID);
    public publication get(int PubID)
    return (publication)PubList.get(PubID);
    public void set(int PubID,publication newpublication)
    PubList.set(PubID, newpublication);
    import cs1.Keyboard;
    import publication;
    import java.util.*;
    public class publicationmain
    public static void main(String args[])
    PublicationContainer pubdatabase = new PublicationContainer();
    int userchoice;
    boolean flag = false;
    while (flag == false)
    System.out.println("------------------------------------Publications--------------------------------");
    System.out.println();
    System.out.println("please Make a Selection");
    System.out.println();
    System.out.println("1 to add publication");
    System.out.println("2 to delete publication");
    System.out.println("0 to quit");
    System.out.println("3 to View all publications");
    System.out.println("4 to Edit a publication");
    System.out.println("5 to select view of publication");
    System.out.println("6 to produce daily summary");
    System.out.println();
    userchoice = Keyboard.readInt();
    switch (userchoice)     
    case 1:
    String PubName;
    String PricePerIssue;
    String Publisher;
    String Pubstatus;
    String Pubtype;
    int PubID;
    System.out.println ("Enter Publication ID:");
    PubID = Keyboard.readInt();
    System.out.println("Enter Publication Name:");
    PubName = Keyboard.readString();
    System.out.println("Enter Publisher Name");
    Publisher = Keyboard.readString();
    System.out.println("Enter Price per Issue:");
    PricePerIssue = Keyboard.readString();
    System.out.println("Enter Publication status");
    Pubstatus = Keyboard.readString();
    System.out.println("Enter Publication type:");
    Pubtype = Keyboard.readString();
    pubdatabase.add (new publication(PubID, PubName, Publisher, PricePerIssue, Pubstatus, Pubtype));
    break;
    case 0:
    flag = true;
    case 2:
    System.out.println ("Enter Publication ID:");
    PubID = Keyboard.readInt();
    pubdatabase.remove (PubID);
    System.out.println ("publication: "+(PubID)+" removed");
    System.out.println();
    break;
    case 3:
    System.out.println (pubdatabase);
    break;
    case 4:
    System.out.println ("Enter Publication to be edited by Publication ID: ");
    PubID = Keyboard.readInt();
    pubdatabase.get(PubID);
    pubdatabase.set(PubID, newpublication);
    default:
    System.out.println("Incorrect Entry");
    }

    Whoops! Anyone spot the mistake?
    I (blush) forgot to re-instate the serial key for the publications after reading them in from disk.
    Works now ;)
    import javax.swing.JComponent;
    import javax.swing.JList;
    import javax.swing.DefaultListModel;
    import javax.swing.JPanel;
    import javax.swing.JOptionPane;
    import javax.swing.JButton;
    import javax.swing.JScrollPane;
    import javax.swing.JLabel;
    import javax.swing.JComboBox;
    import javax.swing.JTextField;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.Dimension;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.Serializable;
    class Publication
         implements Serializable
         private static final String sFileName= "Publications.ser";
         public static final byte UNKNOWN=     0;
         public static final byte HARDBACK=    1;
         public static final byte PAPERBACK=   2;
         public static final byte AUDIO=       3;
         public static final byte BRAIL=       4;
         public static final byte LARGE_PRINT= 5;
         public static final byte INSTOCK=      1;
         public static final byte BACK_ORDER=   2;
         public static final byte OUT_OF_PRINT= 3;
         private static final String[] sTypeNames=
              { "Unknown", "Hardback", "Paperback", "Audio", "Brail", "Large Print" };
         private static final String[] sStatusNames=
              { "Unknown", "In Stock", "Back Order", "Out of Print" };
         private int mId;
         private String mTitle;
         private String mAuthor;
         private String mPublisher;
         private float mPrice;
         private byte mStatus;
         private byte mType;
         private static Object sIdLock= new Object();
         static int sId;
         public Publication(
              String title, String author, String publisher,
              float price, byte status, byte type)
              setTitle(title);
              setPublisher(publisher);
              setAuthor(author);
              setPrice(price);
              setStatus(status);
              setType(type);
              synchronized (sIdLock) {
                   mId= ++sId;
         public int getId() { return mId; }
         public void setTitle(String title) { mTitle= title; }
         public String getTitle() { return mTitle; }
         public void setAuthor(String author) { mAuthor= author; }
         public String getAuthor() { return mAuthor; }
         public void setPublisher(String publisher) { mPublisher= publisher; }
         public String getPublisher() { return mPublisher; }
         public void setPrice(float price) { mPrice= price; }
         public float getPrice() { return mPrice; }
         public void setStatus(byte status)
              if (status >= INSTOCK && status <= OUT_OF_PRINT)
                   mStatus= status;
              else
                   mStatus= UNKNOWN;
         public byte getStatus() { return mStatus; }
         public String getStatusName() { return sStatusNames[mStatus]; }
         public void setType(byte type)
              if (type >= HARDBACK && type <= LARGE_PRINT)
                   mType= type;
              else
                   mType= UNKNOWN;
         public byte getType() { return mType; }
         public String getTypeName() { return sTypeNames[mType]; }
         public String toString ()
              return
                   " id= " +getId() +
                   ", title= " +getTitle() +
                   ", author= " +getAuthor() +
                   ", publisher= " +getPublisher() +
                   ", price= " +getPrice() +
                   ", status= " +getStatus() +
                   " (" +getStatusName() +")" +
                   ", type= " +getType() +
                   " (" +getTypeName() +")";
         private static void addPublication(DefaultListModel listModel) {
              editPublication(listModel, null);
         private static void editPublication(
              DefaultListModel listModel, Publication publication)
              JPanel panel= new JPanel(new BorderLayout());
              JPanel titlePanel= new JPanel(new GridLayout(0,1));
              JPanel fieldPanel= new JPanel(new GridLayout(0,1));
              JTextField fTitle= new JTextField(20);
              JTextField fAuthor= new JTextField();
              JTextField fPublisher= new JTextField();
              JTextField fPrice= new JTextField();
              JComboBox cbStatus= new JComboBox(sStatusNames);
              JComboBox cbType= new JComboBox(sTypeNames);
              fieldPanel.add(fTitle);
              fieldPanel.add(fAuthor);
              fieldPanel.add(fPublisher);
              fieldPanel.add(fPrice);
              fieldPanel.add(cbStatus);
              fieldPanel.add(cbType);
              titlePanel.add(new JLabel("Title:"));
              titlePanel.add(new JLabel("Author:"));
              titlePanel.add(new JLabel("Publisher: "));
              titlePanel.add(new JLabel("Price:"));
              titlePanel.add(new JLabel("Status:"));
              titlePanel.add(new JLabel("Type:"));
              panel.add(titlePanel, BorderLayout.WEST);
              panel.add(fieldPanel, BorderLayout.EAST);
              if (publication != null) {
                   fTitle.setText(publication.getTitle());
                   fTitle.setEditable(false);
                   fAuthor.setText(publication.getAuthor());
                   fPublisher.setText(publication.getPublisher());
                   fPrice.setText("" +publication.getPrice());
                   cbStatus.setSelectedIndex((int) publication.getStatus());
                   cbType.setSelectedIndex((int) publication.getType());
              int option= JOptionPane.showOptionDialog(
                   null, panel, "New Publication",
                   JOptionPane.OK_CANCEL_OPTION,
                   JOptionPane.PLAIN_MESSAGE,
                   null, null, null
              if (option != JOptionPane.OK_OPTION)
                   return;
              String title=
                   fTitle.getText().length() < 1 ? "Unknown" : fTitle.getText();
              String author=
                   fAuthor.getText().length() < 1 ? "Unknown" : fAuthor.getText();
              String publisher=
                   fPublisher.getText().length() < 1 ? "Unknown" : fPublisher.getText();
              float price= 0.0f;
              try { price= Float.parseFloat(fPrice.getText()); }
              catch (NumberFormatException nfe) { }
              byte status= (byte) cbStatus.getSelectedIndex();
              byte type= (byte) cbType.getSelectedIndex();
              if (publication != null) {
                   publication.setAuthor(author);
                   publication.setPublisher(publisher);
                   publication.setPrice(price);
                   publication.setStatus(status);
                   publication.setType(type);
              else {
                   listModel.addElement(
                        new Publication(title, author, publisher, price, status, type));
         private static void deletePublications(JList list, DefaultListModel listModel)
              if (list.getSelectedIndex() >= 0) {
                   Object[] values= list.getSelectedValues();
                   for (int i= 0; i< values.length; i++)
                        listModel.removeElement(values);
         private static DefaultListModel getListModel()
              DefaultListModel listModel;
              try {
                   ObjectInputStream is=
                        new ObjectInputStream(new FileInputStream(sFileName));
                   listModel= (DefaultListModel) is.readObject();
                   is.close();
                   if (listModel.getSize() > 0) {
                        Publication.sId=
                             ((Publication)
                                  listModel.get(listModel.getSize() -1)).getId();
              catch (Exception e) {
                   JOptionPane.showMessageDialog(
                        null, "Could not find saved Publications, creating new list.",
                        "Error", JOptionPane.ERROR_MESSAGE);
                   listModel= new DefaultListModel();
                   // add a known book to the list (I'm pretty sure this one exists ;)
                   listModel.addElement(
                        new Publication("The Bible", "Various", "God", 12.95f,
                             Publication.INSTOCK, Publication.HARDBACK));
              // add a shutdown hook to save the list model to disk when we exit
              final DefaultListModel model= listModel;
              Runtime.getRuntime().addShutdownHook(new Thread() {
                   public void run() {
                        saveListModel(model);
              return listModel;
         private static void saveListModel(DefaultListModel listModel)
              try {
                   ObjectOutputStream os=
                        new ObjectOutputStream(new FileOutputStream(sFileName));
                   os.writeObject(listModel);
                   os.close();
              catch (IOException ioe) {
                   System.err.println("Failed to save Publications!");
                   ioe.printStackTrace();
         public static void main(String args[])
              // store all the publications in a list model which drives the JList
              // the user will see - we save it on exit, so see if there's one on disk.
              final DefaultListModel listModel= getListModel();
              final JList list= new JList(listModel);
              // two panels, the main one for the dialog and one for buttons
              JPanel panel= new JPanel(new BorderLayout());
              JPanel btnPanel= new JPanel(new GridLayout(1,0));
              // an add button, when pressed brings up a dialog where the user can
              // enter details of a new publication
              JButton btnAdd= new JButton("Add");
              btnAdd.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        addPublication(listModel);
              btnPanel.add(btnAdd);
              // a delete button, when pressed it will delete all the selected list
              // items (if any) and then disable itself
              final JButton btnDelete= new JButton("Delete");
              btnDelete.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        deletePublications(list, listModel);
              btnDelete.setEnabled(false);
              btnPanel.add(btnDelete);
              // hook into the list selection model so we can de-activate the delete
              // button if no list items are selected.
              list.getSelectionModel().addListSelectionListener(
                   new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                             if (list.getSelectedIndices().length > 0)
                                  btnDelete.setEnabled(true);
                             else
                                  btnDelete.setEnabled(false);
              // Watch out for double clicks in the list and edit the document
              // selected
              list.addMouseListener(new MouseListener() {
                   public void mouseClicked(MouseEvent e) {
                        if (e.getClickCount() == 2) {
                             editPublication(
                                  listModel, (Publication) list.getSelectedValue());
                   public void mousePressed(MouseEvent e) { }
                   public void mouseReleased(MouseEvent e) { }
                   public void mouseEntered(MouseEvent e) { }
                   public void mouseExited(MouseEvent e) { }
              // Now keep an eye out for the user hitting return (will edit the selected
              // publication) or delete (will delete it)
              // Note: we have do the ugly "pressed" flag because JOptionPane closes
              // on keyPressed and we end up getting keyReleased. Can't use keyTypes
              // because it does not contain the virtual key code 8(
              list.addKeyListener(new KeyListener() {
                   boolean pressed= false;
                   public void keyTyped(KeyEvent e) { }
                   public void keyPressed(KeyEvent e) {
                        pressed= true;
                   public void keyReleased(KeyEvent e) {
                        if (pressed && e.getKeyCode() == e.VK_ENTER) {
                             editPublication(
                                  listModel, (Publication) list.getSelectedValue());
                        else if (pressed && e.getKeyCode() == e.VK_DELETE)
                             deletePublications(list, listModel);
                        pressed= false;
              // Put the list in a scroll pane so we can see it all. Make it resonably
              // wide so we don't have top scroll horizonatly to see most publications
              JScrollPane listScrollPane= new JScrollPane(list);
              listScrollPane.setPreferredSize(new Dimension(640, 300));
              // layout the list and button panel
              panel.add(listScrollPane, BorderLayout.CENTER);
              panel.add(btnPanel, BorderLayout.SOUTH);
              // ok, ready to rumble, lets show the user what we've got
              JOptionPane.showOptionDialog(
                   null, panel, "Publications",
                   JOptionPane.DEFAULT_OPTION,
                   JOptionPane.PLAIN_MESSAGE,
                   null, new String[0], null
              // leg it
              System.exit(0);

Maybe you are looking for

  • How to include columns with a space in name in clientcontext load method in JSOM

    Hi Gurus, I have a situation where I need to read a list that has a column 'Repositary Name'. While I am reading the list in my JSOM I need to load this column in the clientcontext.load method. My code likes this below. this.collListItem = list.getIt

  • Can my iMac be set to type with French characters?

    Hello all! Can my iMac be set to type with French characters? If so, what is the path? And, is there a keyboard overlay to see where the French language characters are located on the keyboard? Thanks!

  • Determining System components/specifications

    I just got a T400 from the Outlet, Refurbished high end model ($3200 list/ $1250 outlet).  When I purchased it I did not print out the specifications, I remember some but not all. I've just unpacked, started charging the battery, and noticed there is

  • Regarding GUI_DOWNLOAD STRING PRB

    hey guys, We are trying to download internal table values to Excel sheet. But string length holding above 8200 is not downloading  to excel completely,getting truncated/showing dump. below is the structure. begin of itab. fld1(10). fld2(20). fld3 typ

  • Rolling back version 10

    How do I  roll back to an earlier version?   11.1 is just too buggy -- I don't like the way it displays podcasts, and I can't add files (.mp3's) or folders.