Function help with strings

I have a list of at least 5000 names in my system and i want to make a search module based on the list of those names.
NAME
Ashish Nanda
Jim Chang
Micheal Douglas
John
Steven Seagal
jim Chang
I want to to create an id column from this list i have and then add it in the table where i will put in names as
Id
ASHISHNANDA
MICHEALDOUGLAS
JOHN
STEVENSEAGAL
JIMCHANG
i KNOW I CAN USE THE UPPER TO CONVERT THE STRINGS IN TO UPPERCASE FORMAT BUT HOW DO I GET RID OF THE SPACES IN BETWEEN WHICH OCCUR AT RANDOM INTERVALS.
Any Suggestions?
Best Regards,
Ashish

It does not work i am using Oracle 8.1
I tried issuing the command but it does not gie no results.
SQL> select replace('tiny tim','') from dual;
REPLACE(
tiny tim

Similar Messages

  • Help With String parsing

    Hey guys,
    I need some help with String Parsing. i hope experts here will help me.
    i'm reading a text file and getting data as String in this format
    *ABR, PAT MSSA        2009       7001    B   ABC       Y
    *VBR, SAT ZSSA        2008       5001    A   CED       N
    *ABC, AAT CSSA        5008       001     A   AZX       N
    *CBC, CAT FSSA        308        5001    A   XCV       N
    Now from following lines i have to extract Number data i.e. 2009 and 7001 from 1st line. 2008 and 5001 from 2nd line and so on.
    Can anyone pls suggest me any way to get the data that i want from these Strings
    Thanks for your time to read this.
    Regards,
    sam

    Thanks for the reply
    Data length can vary. ABR, PAT is the last name, First Name of the Users.
    it can be following or any other combination. i just need 2 set of numbers from the complete line rest i can ignore. Any other way to get that
    *ABRaaassd, PATfffff MSSA 2009 7001 B ABC Y
    *VBRaa, SATaa ZSSA 2008 5001 A CED N
    *ABC, AAT CSSA 5008 001 A AZX N
    *CBC, CAT FSSA 308 5001 A XCV N                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Help with string object code

    Hello,
    First off thanks in advance to anyone who helps. I am trying to write a program that using a class string object to convert this kind of "text speech" to english. For example if the user inputs "HowAreYou?", I want the program to output "How are you?" I am having too much trouble with strings for some reason. This is what I have so far and I am not sure where to go from here. Should I use a do loop to check through the input string until it is done seperating the words? And how should I go about doing that?
    import java.util.Scanner;
    public class P8
    public static void main( String args[] )
    char choice;
    String line = null;
    String answer = null;
    Scanner scan = new Scanner(System.in);
    do
    System.out.println();
    System.out.print("ENTER TextSpeak sentence(s): ");
    line = scan.nextLine();
    System.out.print( "Converted to English: \t ");
    System.out.print( textSpeaktoEng( line ) );
    System.out.println();
    System.out.print("Want more TextSpeak?\t\t ");
    answer = scan.next();
    choice = answer.charAt(0);
    if( scan.hasNextLine() )
    answer = scan.nextLine();
    }while(choice != 'N' && choice != 'n');
    public static String textSpeakToEng(String s)
    String engStr = null;
    if( Character.isUpperCase( s.charAt(j) ) )
    engStr += ? ?;
    engStr += Character.toLowerCase( s.charAt(j) );
    scan.close();
    }

    I got my program to compile and run but I have a problem. If I input something like "ThisForumIsGreat" it will output just "t f i g" in lower case letters. Any suggestions?
    import java.util.Scanner;
    public class P8
    public static void main( String args[] )
       char     choice;                          // Repeat until n or N                                             
       String line   = null;                     // Sentences to toTextSpeak
       String answer = null;                     // Repeat program scan
       Scanner scan = new Scanner(System.in);    // Read from keyboard
       do
          System.out.println();
          System.out.print("ENTER TextSpeak sentence(s): ");
          line = scan.nextLine();                // Read input line
          System.out.print( "Converted to English: \t    ");
          System.out.print( textSpeakToEng( line ) );
          System.out.println();
          System.out.print("Want more TextSpeak?\t\t ");
          answer = scan.next();                  // Read line, assign to string
          choice = answer.charAt(0);             // Assign 1st character
          if( scan.hasNextLine() )               // <ENTER> character
            answer = scan.nextLine();            // Read line, discard
      }while(choice != 'N' && choice != 'n');    // Repeat until input start n or N
    public static String textSpeakToEng(String s)
       String engStr = null;  
       int i;  
       for ( i = 0; i < s.length(); ++i )
       if( Character.isUpperCase( s.charAt(i) ) )
         engStr += " ";                                  // Append 1 blank space
         engStr += Character.toLowerCase( s.charAt(i) ); // Append lowercase
       return( engStr );
    }

  • Max function coupled with string concat....please help...

    Dear All,
    I do have to solve one query which requirement is below :
    Basic data in table looks like this:
    SEQ NO PCode Last_updated_date
    1     AA 1-Feb-2008
    1     Ab 2-Jan-2009
    1     Ac 3-Jan-2009
    2     AA 5-Jan-2009
    2     AD 31-Dec-2008
    2     AF 31-Oct-2008
    3     AK 1-Jan-2009
    3     GH 2-Jan-2009     
    3     AA 3-Jan-2009
    Now i need the output like :
    I need max of timestamp under each seqence no (i mean groupby) (i am really easy to find this) but it should show all pcode concated while displaying the result..
    okay.. the below is required out put..:
    for example in for seq 1 number one..max of timestamp is 1-Feb-2008 with pcode AA..so it should display like
    seqno Pcode max(timestamp)
    1 AAABAC 1-Feb-2008
    (logic is it should select max(timestamp) record and concat all all other pcode(only) to existing pcode eventough their timestamp is not max)
    like this for all other sequence groups...
    Please help..is this possible in a sqlquery to include this logic...
    Thanks for help
    ASP
    Edited by: Onenessboy on Feb 24, 2009 3:00 AM

    Hi,
    Check the query below:
    With t
    As
    (SELECT 1 AS seq_no,  'AA' as pcode, '1-Feb-2008' last_updated_date from dual
    union all
    Select 1, 'Ab', '2-Jan-2009' from dual
    union all
    Select 1, 'Ac', '3-Jan-2009' from dual
    union all
    Select 2, 'AA', '5-Jan-2009' from dual
    union all
    Select 2, 'AD', '31-Dec-2008' from dual
    union all
    Select 2, 'AF', '31-Oct-2008' from dual
    union all
    Select 3, 'AK', '1-Jan-2009' from dual
    union all
    Select 3, 'GH', '2-Jan-2009' from dual
    union all
    Select 3, 'AA', '3-Jan-2009' from dual
    Select seq_no,replace(max(pcode),'/','') pcode,min(last_updated_date) timestamp
    from
    (Select seq_no,sys_connect_by_path(pcode,'/') pcode ,to_date(last_updated_date,'DD-MON-YYYY') last_updated_date
    from t
    connect by prior seq_no = seq_no
    and
    prior to_date(last_updated_date,'DD-Mon-YYYY') &gt;to_date(last_updated_date,'DD-Mon-YYYY') )
    group by seq_no
    /Let me know if this helps.
    Regards,
    Vinod

  • Urgent help with string tokenizing.

    Hello Everyone,
    I'm 4 months new to Java and JSP.
    Can some one help me with a small favor please, my program below reads from a file and Tokenize the string, the top layer of the string is OK however I want to write another method to tokenize off of the top layer it must be in a separate method because I want to call the method on a JSP page. Can someone view my code and help me with the other method please.
    Thanks
    KT
    package dev;
    import java.io.*;
    import java.util.*;
    public class RoundDetail2
    public String string_gameID;
    public String string_roundID;
    public String string_bet;
    public String string_win;
    public String string_roundDetail;
    public String string_date_time;
    public String tokenizer_topLayer;
    public String readDetail_topLayer;
    public static final String SUITS[] = {" ", "Clubs", "Hearts", "Spades", "Diamonds", "Joker", "FaceDown"};
    public static final String VALUES[] = {"Joker ","Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
    public static final String SuitVALUES[] = {" ","1","2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"};
    public RoundDetail2() throws FileNotFoundException
    DataInputStream inFile=
                 new DataInputStream(
                    new BufferedInputStream(
                   new FileInputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/WEB-INF/classes/dev/Data_452SY2.txt")));
    try { 
                 if((readDetail_topLayer = inFile.readLine()) != null)
              StringTokenizer tokenizer_topLayer = new StringTokenizer(readDetail_topLayer,"\t", true);
                   if (tokenizer_topLayer.hasMoreTokens())
                        string_gameID = tokenizer_topLayer.nextToken();
                        string_roundID = tokenizer_topLayer.nextToken();                                   
         catch(IOException e)
                    System.out.println(e.getMessage());
         

    If you are trying to read tab delimited file and tokenize the contents, the code should be as below:
    package dev;
    import java.io.*;
    import java.util.*;
    public class RoundDetail2 {
         public String string_gameID;
         public String string_roundID;
         public String string_bet;
         public String string_win;
         public String string_roundDetail;
         public String string_date_time;
         public String tokenizer_topLayer;
         public String readDetail_topLayer;
         public static final String SUITS[] = {" ", "Clubs", "Hearts", "Spades", "Diamonds", "Joker", "FaceDown"};
         public static final String VALUES[] = {"Joker ","Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
         public static final String SuitVALUES[] = {" ","1","2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"};
         String gameInfoText = "";
         public RoundDetail2() throws FileNotFoundException
              DataInputStream inFile = new DataInputStream(new BufferedInputStream(
                                            new FileInputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/WEB-INF/classes/dev/Data_452SY2.txt")));
              try
                   while((readDetail_topLayer = inFile.readLine()) != null)
                        gameInfoText += readDetail_topLayer;
              }     catch(IOException e)
                   System.out.println(e.getMessage());
         public void getGameInfo()
              StringTokenizer tokenizer_topLayer = new StringTokenizer(gameInfoText,"\t", false);
              while (tokenizer_topLayer.hasMoreTokens())
                   string_gameID = tokenizer_topLayer.nextToken();
                   string_roundID = tokenizer_topLayer.nextToken();
                   System.out.println(string_gameID+" : "+string_roundID);
         public static void main(String[] args)
              try
                   RoundDetail2 roundDetail = new RoundDetail2();
                   roundDetail.getGameInfo();
              }catch(Exception e){}
    Test if it works for you by running at command prompt.
    Goodluck
    -Mak

  • Need help with string field formula

    Post Author: dshallah
    CA Forum: Formula
    What I am trying to accomplish:
    The report has item numbers and each item number has the
    potential to be associated with up to three u2018binsu2019. So the fields are u2018item
    numberu2019, u2018bin1, u2018bin2u2019 and u2018bin3u2019.
    I tried to write a u2018if thenu2019 statement that would only show
    records that had a value of less than 1 in each u2018binu2019 field. When I try to
    write the statement I get a message that says u2018A string is required hereu2019 and
    it highlights the number 1 in my statement. I have a feeling itu2019s because the u2018binu2019
    fields are string fields and not number fieldsu2026? So I am not sure the proper
    procedure to correct this. Thus help is needed and appreciated.
    Here is what I wrote:
    if {IC_LOC_HIST.BIN_NAME_1} < 1 then
    {IC_LOC_HIST.BIN_NAME_1}
    What is correct way to write a statement that will show me
    the zero values in each column of bin fields?
    Thanks!

    Post Author: bettername
    CA Forum: Formula
    You must have a non-numeric value in there somewhere - up in the top left of the formula editor window, it'll show you the variables you've passed to the formula, which should help track down what's going on.
    You could try and check that the value is a number first by using something like:
    if isnull({IC_LOC_HIST.BIN_NAME_1}) = false and isnumeric({IC_LOC_HIST.BIN_NAME_1}) = false and then "Error - Should be a Number!"
    else
    if isnumeric({IC_LOC_HIST.BIN_NAME_1}) = true and tonumber({IC_LOC_HIST.BIN_NAME_1})<1 then {IC_LOC_HIST.BIN_NAME_1})

  • Can anyone help with string manipulation please?

    I am trying to change this string 43180-1-0001-37 into the following expression 43181-0001-37
    It is a string for Project No + Job Phase + Drawing No + Item No.
    The reduction of '43180' to '4318' is causing me the problem, I have the concatenation.
    Current report code is
    SELECT Os.[Orderno-o] As 'Order Number'
    ,Ph.PH_PHASE_NO + '.' + Re.REQUISITION_NUMBER As 'Req. Number'
    ,Pl.ID As 'Item ID'
    ,@CurrentProjectNumber + '-' + Ph.PH_PHASE_NO + '-' + Dr.DRAWING_NO + '-' + Cast(Pl.ITEM_NO As varchar(max)) As 'Drg & Item No.'
    It is this line giving me the problem?
    ,@CurrentProjectNumber + '-' + Ph.PH_PHASE_NO + '-' + Dr.DRAWING_NO + '-' + Cast(Pl.ITEM_NO As varchar(max)) As 'Drg & Item No.'

    Hi uh... Mr. Rubbish at SQL :)
    Unfortunately, there are many elements in your questions which aren't clear:
    1. What is the content in your columns PH_PHASE_NO, DRAWING_NO, ITEM_NO and what is their data type?
    2. What is the content of the variable @CurrentProjectNumber and what is its data type?
    3. It's unclear what is the logic behind the "reduction" of '43180' to '4318'. Do you want to remove trailing zeros? Shorten the value by one character? Because from what I see in your first sentence, it seems like you simply want to add 1 to '43180'
    and turn it into '43181'. That's a simple +1 operation. I also notice that you want to remove the "Job Phase" part from the string (which is "1" in your case)? Or do you need to add its value to the "Project No" (43180)? It's
    all quite confusing.
    Clarification would be highly appreciated.
    I would suggest, if you can, to please explain what you need NOT by specific examples, but by explaining your requirements IN GENERAL. In other words, don't use specific values like '43180', but start with a variable like 'X', and then let us know specifically
    what operation you want to perform on it (e.g. 'add 1' / 'remove trailing zeros' / 'shorten by one character' / 'add to it the value of some column' etc.). This will make it easier to understand the algorithm needed.
    Eitan Blumin; SQL Server Consultant - Madeira Data Solutions;

  • Need a little help with strings

    So I would like to have the user input a month by using the abbreviation ex. (mar or apr) instead. So I want month to be a string right? When I tried that I get an error. What should this look like?
    import java.util.*;
    public class MonthSwitch
      static Scanner console = new Scanner(System.in);
      public static void main(String[] args)
        int month;
        System.out.print("Enter a Month: ex. Jan, Feb, Mar ect...");
        month = console.nextInt();
        System.out.println();
        switch (month)
          case 1: System.out.println("First Quarter");
          case 2: System.out.println("First Quarter");
          case 3: System.out.println("First Quarter");
                  break;
          case 4: System.out.println("Second Quarter");
          case 5: System.out.println("Second  Quarter");
          case 6: System.out.println("Second  Quarter");
                  break;
          case 7: System.out.println("Third Quarter");
          case 8: System.out.println("Third Quarter");
          case 9: System.out.println("Third Quarter");
                  break;
          case 10: System.out.println("Fouth Quarter");
          case 11: System.out.println("Fouth Quarter");
          case 12: System.out.println("Fouth Quarter");
                  break;
          default: System.out.println("Sorry Input is Invalid");
    }Edited by: NewJavaKid on Apr 29, 2009 10:47 PM

    If you use an enum construct, then you can create a switch that operates on the abbreviated month value. Note that I made a correction in the Scanner input code, and converted the input to lowercase (to assure a match with the enum) in case capitals were used. The switch was revised to work correctly with enums, which requires the try/catch to catch illegal input.
    import java.util.Scanner;
    public class Xy
        static Scanner console = new Scanner(System.in);
        enum Month
            jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec
        public static void main(String[] args)
            System.out.print("Enter a Month: ex. Jan, Feb, Mar etc...");
            String shortMonth = console.next().toLowerCase();
            System.out.println();
            try
                switch (Month.valueOf(shortMonth))
                    case jan:
                    case feb:
                    case mar:
                        System.out.println("First Quarter");
                        break;
                    case apr:
                    case may:
                    case jun:
                        System.out.println("Second  Quarter");
                        break;
                    case jul:
                    case aug:
                    case sep:
                        System.out.println("Third Quarter");
                        break;
                    case oct:
                    case nov:
                    case dec:
                        System.out.println("Fouth Quarter");
            catch (IllegalArgumentException iae)
                System.out.println("Sorry, input is invalid");
    }

  • Help with String/ and or Array loading and comparing

    Hi all,
    I'm having some problems with trying to find the best way to achieve the following on a Poker Dealing program. I randomly shuffle a 52 card deck of playing cards and deal out 5 cards. Cool...
    Now I have to go back thru the String and determine if my hand of cards contains
    a pair
    2 pair
    3 of a kind
    Full House
    etc etc
    I am trying to do String comparisons (there is an empty compareCards method in my code right now, but I'm getting a bit frustrated as to find the best way to do it... Would an array load in a separate method be a better way???? What I need to do is after I load my hand , is to display a message stating a pair, 3 of a kind , etc etc.....
    Thanks in advance
    Mike
    Here is my code (please don't laugh too hard - I'm an old COBOL/Oracle guy):
    // Card shuffling and dealing program
    // Java core packages
    import java.awt.*;
    import java.awt.event.*;
    // Java extension packages
    import javax.swing.*;
    public class DeckOfCards extends JFrame {
    private Card deck[];
    private Card hand[];
    private int currentCard;
    private JButton dealButton, shuffleButton;
    private JTextArea outputArea ;
    private JTextField displayField;
    private JLabel statusLabel;
    // set up deck of cards and GUI
    public DeckOfCards()
    super( "Poker Game" );
    String faces[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
    String suits[] = { "Hearts", "Diamonds", "Clubs", "Spades" };
    String display = "" ;
    deck = new Card[ 52 ];
    currentCard = -1;
    // populate deck with Card objects
    for ( int count = 0; count < deck.length; count++ )
    deck[ count ] = new Card( faces[ count % 13 ],
    suits[ count / 13 ] );
    // set up GUI and event handling
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // shuffle button
    shuffleButton = new JButton( "Shuffle cards" );
    shuffleButton.addActionListener(
    // anonymous inner class
    new ActionListener() {
    // shuffle deck
    public void actionPerformed( ActionEvent actionEvent )
    displayField.setText( "" );
    shuffle();
    displayField.setText( "The Deck is Shuffled" );
    statusLabel.setText( "" );
    } // end anonymous inner class
    ); // end call to addActionListener
    container.add( shuffleButton );
    // Deal button
    dealButton = new JButton( "Deal Hand" );
    dealButton.addActionListener (
    // anonymous inner class
    new ActionListener() {
    // deal 5 cards
    public void actionPerformed( ActionEvent actionEvent )
    outputArea.setText( "" ) ;
    displayField.setText( "" );
    for ( int cctr = 1 ; cctr <= 5; cctr++ ){     
    Card dealt = dealCard();
    if ( dealt != null ) {
    outputArea.append( dealt.toString()+"\n" );
    else {
    displayField.setText( "No more cards left" );
    statusLabel.setText( "Shuffle cards to continue" );}
    } // end for structure
    compareCards() ;
    } // end action
    } // end anonymous inner class
    ); // end call to addActionListener
    container.add( dealButton );
    outputArea = new JTextArea (10, 20) ;
    outputArea.setEditable( false ) ;
    container.add( outputArea ) ;
    displayField = new JTextField( 20 );
    displayField.setEditable( false );
    container.add( displayField );
    statusLabel = new JLabel();
    container.add( statusLabel );
    setSize( 275, 275 ); // set window size
    show(); // show window
    // shuffle deck of cards with one-pass algorithm
    public void shuffle()
    currentCard = -1;
    // for each card, pick another random card and swap them
    for ( int first = 0; first < deck.length; first++ ) {
    int second = ( int ) ( Math.random() * 52 );
    Card temp = deck[ first ];
    deck[ first ] = deck[ second ];
    deck[ second ] = temp;
    dealButton.setEnabled( true );
    public void compareCards()
    public Card dealCard()
    if ( ++currentCard < deck.length )
    return deck[ currentCard ];
    else {       
    dealButton.setEnabled( false );
    return null;
    // execute application
    public static void main( String args[] )
    DeckOfCards app = new DeckOfCards();
    app.addWindowListener(
    // anonymous inner class
    new WindowAdapter() {
    // terminate application when user closes window
    public void windowClosing( WindowEvent windowEvent )
    System.exit( 0 );
    } // end anonymous inner class
    ); // end call to addWindowListener
    } // end method main
    } // end class DeckOfCards
    // class to represent a card
    class Card {
    private String face;
    private String suit;
    // constructor to initialize a card
    public Card( String cardFace, String cardSuit )
    face = cardFace;
    suit = cardSuit;
    // return String represenation of Card
    public String toString()
    return face + " of " + suit;
    } // end class Card

    You could have the original face values as integers, thus Ace = 1, Jack = 11 (it'll be easy enough to display the proper values AJQK if you keep your string array and just display whatever corresponds to the value held in your int array).
    Each player gets an array of five cards. You could the loop through each hand and increment values held in another array by one according to the value of the card. Haven't coded the following up but it should work I think.
    // hand [ ] represents the cards held by that player
    int handChecker [ ] = new int [14]
    for (int counter = 0; counter < 5; ++ counter)
    // 1st card is an Ace. handChecker [1] will be incrementd by one and so on
    // 2nd card is a 9. handChecker[9] will be incremented by one.
    handChecker[hand[counter]] += 1;
    // Loop through the array handChecker to find pairs etc.
    boolean pair = false;
    bollean tofk = false;
    for (int counter = 1; counter < 14; ++ counter)
    if (handChecker[counter] == 2)
    pair = true;
    if (handChecker[counter] == 3)
    tofk = true;
    if (pair)
    // player has a pair
    if(tofk)
    // player has three of a kind
    if(pair && tofk)
    // player has a full house

  • Help with string.valueof

    I have the following code which is meant to read in a file into text boxes and let me scroll through all the items in the file.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import bank.*;
    public class ReadSequentialFile extends JFrame {
       private ObjectInputStream input;
       private BankUI userInterface;
       private JButton nextButton, openButton, nextRecordButton ;
       private Store store = new Store(50);
         private Employee employeeList[] = new Employee[50];
         private int count = 0, next = 0;
       // Constructor -- initialize the Frame
       public ReadSequentialFile()
          super( "View Data" );
          // create instance of reusable user interface
          userInterface = new BankUI( 8 );  // eight textfields
          getContentPane().add( userInterface, BorderLayout.CENTER );
          // get reference to generic task button doTask1 from BankUI
          openButton = userInterface.getDoTask1Button();
          openButton.setText( "Open File" );
          // register listener to call openFile when button pressed
          openButton.addActionListener(
             // anonymous inner class to handle openButton event
             new ActionListener() {
                // close file and terminate application
                public void actionPerformed( ActionEvent event )
                   openFile();
             } // end anonymous inner class
          ); // end call to addActionListener
          // register window listener for window closing event
          addWindowListener(
             // anonymous inner class to handle windowClosing event
             new WindowAdapter() {
                // close file and terminate application
                public void windowClosing( WindowEvent event )
                   if ( input != null )
                             closeFile();
                   System.exit( 0 );
             } // end anonymous inner class
          ); // end call to addWindowListener
          // get reference to generic task button doTask2 from BankUI
          nextButton = userInterface.getDoTask2Button();
          nextButton.setText( "Next Record" );
          nextButton.setEnabled( false );
          // register listener to call readRecord when button pressed
          nextButton.addActionListener(
             // anonymous inner class to handle nextRecord event
             new ActionListener() {
                // call readRecord when user clicks nextRecord
                public void actionPerformed( ActionEvent event )
                   readRecord();
             } // end anonymous inner class
          ); // end call to addActionListener
          nextRecordButton = userInterface.getDoTask3Button();
          nextRecordButton.setText( "Get Next Record" );
          nextRecordButton.setEnabled( false );
          // register listener to call readRecord when button pressed
          nextRecordButton.addActionListener(
             // anonymous inner class to handle nextRecord event
             new ActionListener() {
                // call readRecord when user clicks nextRecord
                public void actionPerformed( ActionEvent event )
                   getNextRecord();
             } // end anonymous inner class
          ); // end call to addActionListener
          pack();
          setSize( 600, 300 );
          setVisible( true );
       } // end ReadSequentialFile constructor
       // enable user to select file to open
       private void openFile()
          // display file dialog so user can select file to open
          JFileChooser fileChooser = new JFileChooser();
          fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
          int result = fileChooser.showOpenDialog( this );
          // if user clicked Cancel button on dialog, return
          if ( result == JFileChooser.CANCEL_OPTION )
             return;
          // obtain selected file
          File fileName = fileChooser.getSelectedFile();
          // display error if file name invalid
          if ( fileName == null || fileName.getName().equals( "" ) )
             JOptionPane.showMessageDialog( this, "Invalid File Name",
                "Invalid File Name!", JOptionPane.ERROR_MESSAGE );
          else {
             // open file
             try {
                input = new ObjectInputStream(
                   new FileInputStream( fileName ) );
                openButton.setEnabled( false );
                nextButton.setEnabled( true );
             // process exceptions opening file
             catch ( IOException ioException ) {
                JOptionPane.showMessageDialog( this, "Error Opening File",
                   "Error", JOptionPane.ERROR_MESSAGE );
          } // end else
       } // end method openFile
       // read record from file
       public void readRecord()
          Employee record;
          // input the values from the file
          try {
            record = ( Employee ) input.readObject();
         employeeList[count++]= record;
         store.add(record);
              store.displayAll(); // displays store in terminal window
              System.out.println("Count is " + store.getCount());
             // create array of Strings to display in GUI
             String values[] = { String.valueOf(record.getName()),
             String.valueOf(record.getGender()),
              String.valueOf( record.getStartDate() ),
             String.valueOf( record.getID() ),
               String.valueOf( record.getDateOfBirth() ) };
             // display record contents
             userInterface.setFieldValues( values );
          // display message when end-of-file reached
          catch ( EOFException endOfFileException ) {
             nextButton.setEnabled( false );
          nextRecordButton.setEnabled( true );
             JOptionPane.showMessageDialog( this, "No more records in file",
                "End of File", JOptionPane.ERROR_MESSAGE );
          // display error message if class is not found
          catch ( ClassNotFoundException classNotFoundException ) {
             JOptionPane.showMessageDialog( this, "Unable to create object",
                "Class Not Found", JOptionPane.ERROR_MESSAGE );
          // display error message if cannot read due to problem with file
          catch ( IOException ioException ) {
             JOptionPane.showMessageDialog( this,
                "Error during read from file",
                "Read Error", JOptionPane.ERROR_MESSAGE );
       } // end method readRecord
       private void getNextRecord()
               Employee record = employeeList[next++%count];//cycles throught accounts
          //create aray of string to display in GUI
          String values[] = {String.valueOf(record.getName()),
             String.valueOf(record.getGender()),
              String.valueOf( record.getStartDate() ),
             String.valueOf( record.getID() ),
               String.valueOf( record.getDateOfBirth() ) };
      // close file and terminate application
       private void closeFile()
          // close file and exit
          try {
             input.close();
             System.exit( 0 );
          // process exception while closing file
          catch ( IOException ioException ) {
             JOptionPane.showMessageDialog( this, "Error closing file",
                "Error", JOptionPane.ERROR_MESSAGE );
             System.exit( 1 );
       } // end method closeFile
       public static void main( String args[] )
          new ReadSequentialFile();
    } // end class ReadSequentialFileMy problem is when i compile the code i get the following errors:
    ReadSequentialFile.java:181: getStartDate(Date) in Employee cannot be applied to
              String.valueOf( record.getStartDate() ),
                                    ^In the employee class I did getStartDate like:
         public Date getStartDate(Date sDate)
              return start;
         }Can anybody tell me why i get this error and how to solve it?

    so in
    the employee class i need to chnage the getDate
    method?Well, it's your class, so it's up to you to know what that method is supposed to do, to give it a signature that allows it to be called with the data to do its job, and the pass it the right data when you call it.
    Don't think only about how to make the compiler happy. Think about what you're trying to accomplish and in what way the current code doesn't do that. The compiler can only really detect syntactical errors, but sometimes those errors arise as the result of logic errors in your mental picture of the steps to follow. So take the compiler's complaints as a hint to reexamine what you're doing and see if it makes sense.

  • Code help with string array

    I have declared a String array as
    String[] records;
    Later in the code I wrote
    records[records.length] = qualifiedRecDefName.substring(lastIndex+1, qualifiedRecDefName.length());
    I am getting a NullPointerException. I see that records is null. How can I correct this. Thanks.

    You have to create your array using new.String[] records = new String[10];Also, arrays go from 0 to length-1, so if you want to access the last item, it's records[records.length-1]as long as records.length > 0.

  • Help with String Question

    while(more){
                   System.out.print("Code:");
              ProductCode = in.readLine();
              if (!(ProductCode.equals("A01")) || !(ProductCode.equals("A28")) || ! (ProductCode.equals("B52")) || !(ProductCode.equals("B12")) || (!ProductCode.equals("C43"))
                        || !(ProductCode.equals("C63")) || !(ProductCode.equals("D24")) || !(ProductCode.equals("D90"))){
                   System.out.println("Check the product code again");
              }

    //*Read in the Product Code and the quantity the buyer wants
              while(more) {
                   System.out.print("Code:");
                   ProductCode = in.readLine();
                   if (ProductCode.equals("XX")) {
                        more = false;
                   else if (!(ProductCode.equals("A01") || ProductCode.equals("A28") || ProductCode.equals("B52") ||ProductCode.equals("B12") || ProductCode.equals("C43")
                        || ProductCode.equals("C63") || ProductCode.equals("D24") || ProductCode.equals("D90"))){
                        System.out.println("Check the product code again");
                   else {     
                        int j = 0;
                        ProdTemp[j] = ProductCode;
                        System.out.print("Quantity:");
                        ProductNum = in.readLine();
                        ProductQuantity = Integer.parseInt(ProductNum);
                        Quantity[j]=ProductQuantity;          
                        j++;
                        NoOfItems++;
                        TotalQuantity = Quantity[j] + TotalQuantity;
    //*Display the list of items the user is buying
                    for(int i=0;i<NoOfItems;i++)
                   if (ProdTemp.equals("A01")){
                        Cost = Quantity[i]*15.99;
                        System.out.println("Vitamin F, 260 tablets, 50mg\t"+Quantity[i]+"@ $15.99\t\t"+NumberFormat.getCurrencyInstance().format(Cost));     
    etc........
    i always get a java.lang.NULLPointerException when i purposely type in the wrong product code..but when all the product code are right..there is no error..can anyone help me debug?

  • Function help with corresponding boxes

    I have an assignment where I have to add a number to the corresponding box to its left, but it seems really piecemeal to do it one by one. Is there a faster way? (I have to calculate Absolute Deviation)

    Ashley,
    the "boxes" are called cells.  you can fill cells with a formula by selecting a cell with the formula in it already, the copy the cell.
    no select ALL the cells you want to fill and paste .  If you happen to want to fill the cells in a column with the same formula, enter the formula in the first row of the column, then select the cell, then copy.  Now click the column header (the letter at the top) to highlight every cell of that column, paste.

  • Help with string

    hi,
    i wont to add '-' to field of char 7 in the
    e.g.
    12-2345
    ab-cdef
    regards

    Hi
    Check this Small Program ..
    Hope it helps..
    DATA : a type char7 value '123456' ,
           b type char1 value '-' .
    DATA : c type char5 ,
            d type char5 .
    sy-fdpos = 2 .
            C = a+0(sy-fdpos).
            D = a+sy-fdpos.
            CONCATENATE c '-' d INTO a .
            WRITE a .
    Thanks
    Praveen

  • Need help with trim and null function

    Hi all,
    I need help with a query. I use the trim function to get the first three characters of a string. How do I write my query so if a null value occurs in combination with my trim to say 'Null' in my results?
    Thanks

    Hi,
    Thanks for the reply. What am I doing wrong?
    SELECT trim(SUBSTR(AL1.user_data_text,1,3)),NVL
    (AL1.user_data_text,'XX')
    FROM Table
    I want the XX to appear in the same column as the
    trim.The main thing you're doing wrong is not formatting your code. The solution may become obvious if you do.
    What you're saying is:
    SELECT  trim ( SUBSTR (AL1.user_data_text, 1, 3))
    ,       NVL ( AL1.user_data_text, 'XX' )
    FROM    Tablewhich makes it clear that you're SELECTing two columns, when you only want to have one.
    If you want that column to be exactly like the first column you're currently SELECTing, except that when that column is NULL you want it to be 'XX', then you have to apply NVL to that column, like this:
    SELECT  NVL ( trim ( SUBSTR (AL1.user_data_text, 1, 3))
                , 'XX'
    FROM    Table

Maybe you are looking for

  • ITunes keeps saying damaged library

    Dunno whats happened but everytime now when i connect my ipod video itunes always pop up with an error message before it opens saying something along the lines of 'itunes library is damaged, do you want to replace this file' or something like that, a

  • Air play icon is gone on all devices

    my apple tv airplay isnt showing up on any of my devices , ive restarted everthing. even did a restore on the apple tv. 

  • Time out of the Query

    Sdn Im getting Time out for one query while excuting in PRD system. That query filter field setting is Only values Infoprovider. But DEV Im able to excute the same query, but in this system that field setting is Only posted values in navigation advan

  • I want to display the DFF fields in OBIEE reports

    Hello, we have a requirement to show DFFs in OBIEE reports and i wanted to understand: - Will we have to create a custom column mapping in Informatica and custom field in data warehose table? - Should we modify the vanilla content or seprate code to

  • Phoronix: Is Arch Linux Really Faster Than Ubuntu?

    Hello I've just love that benchmarks. Here's the link to the article: http://www.phoronix.com/scan.php?page=a - ster&num=6 What do you think about this? (I don't want to start flamewar !) Thanks.