Take out spaces from a string

I got a StringTokenizer:
while ((fullText = in.readLine()) != null) {
    ++line;
    StringTokenizer tokenizer = new StringTokenizer(fullText, "=");
}It take my fullText string "key = value" into "key " and " value", I want to take out those white space, someone?

If you do:while ((fullText = in.readLine()) != null) {
    ++line;
    StringTokenizer tokenizer = new StringTokenizer(fullText, "=");
    String key = tokenizer.nextToken().trim();
    String value = tokenizer.nextToken().trim();
}Only the leading and trailing whitespaces of key and value will be discarded.
Regards

Similar Messages

  • Stripping extra white space from a string

    I am trying to strip extra spaces from a string, so it there are 2 or more spaces between a word I want to remove all but one. I am trying the following code
    getStringTwo().replaceAll("/\s+/is","");
    but all I get is an error saying Invalid escape sequence
    Thanks
    G

    >
    This strips out all the whitespace. I ended up
    getting round it by walking through the string and
    checking the values of each char and comparing that
    to the next value. What a wast of effortt A small modification of my earlier post gives -
    public class Test040320a
        public static void main(String[] args)
            String str = "this    is       a \t test";
            str = str.replaceAll("\\s+"," ");
            System.out.println(str);
    }

  • How to take the values from a  String ( CSV   values).

    Hi All,
    I am passing csv String to a procedure as in parameter,but I have to take the values from a csv String one by one.Please let me know Is there any StringTokenizer function in oracle to take values like in java. Here is my javacode.
    import java.util.StringTokenizer;
    public class Sample {
         public static void main(String[] args) {
              String s="one,two,three,four,five";
              StringTokenizer stringTokenizer=new StringTokenizer(s,",");
              System.out.println( stringTokenizer.countTokens());
              System.out.println(stringTokenizer.hasMoreTokens());
              while(stringTokenizer.hasMoreTokens()){
                        System.out.print(stringTokenizer.nextToken());
    o/p: one two three four five

    Something based around one of these two methods should assist...
    select substr( the_string 
                  , decode( level, 1, 1, instr(the_string,',',1,level-1)+1)
                  , decode( instr(the_string,',',1,level), 0, length(the_string), instr(the_string,',',1,level) - decode( level, 1, 0, instr(the_string,',',1,level-1))-1)
                  ) the_value
                  from ( select '10,12,20,30,30,3,12,12,56' the_string
                         from dual
                  connect by level < length(replace(translate(the_string,'01234567890','00000000000'),'0')) + 2
    or
    SQL> select REGEXP_SUBSTR ('a,b,c,d,e', '[^,]+', 1, level) from dual connect by level<=5
      2  /
    REGEXP_SU
    a
    b
    c
    d
    e
    SQL>

  • Trim Space from a string

    Hello All,
    I need to trim space from beginning and end of a string.
    For example -
    astring = ' hello123 '.
    I need to get astring as 'hello123'.
    Thanks in advance.
    Viren

    Hi Viren,
    You can code like this
    WRITE ASTRING TO ASTRING NO-GAP.
    Hope this will help.
    Regards,
    Ferry Lianto

  • Getting rid of trailing space from a string variable

    I need to delete trailing blank spaces in a string variable. Is there a method that can do the job?
    Thanks

    String.trim(). Example: " booh! ".trim() returns "booh!".

  • HT201412 how can i take out recordes from my iphone

    pleas help
    i have recordes on my iphone and i want to take them out from the memory dvice into my pc

    For iTunes purchased content, without syncing: File>Transfer Purchases. Music ripped on your own requires third party software, like this:
    http://www.wideanglesoftware.com/touchcopy/index.php

  • Cant take out System from Sleep!

    When my T400 goes to sleep running on battery I am not able to take it back to normal. It seems like it is running but screen is blank. Even when I press power button one time nothing works and it is same with the Function Key. I have to shut down by keep pressing the power button and then resart it again. plz can anybody let me know what is going on here?

    Hi keepfaith,
    You can try the things in this thread to see if they fix your problem.
    Good luck,
    Frank
    Results of Your Ideal Business-Class Laptop survey, concluded 2009-07-29.
    Did someone help you?
    Say thanks! with a kudo.
    Even better: Pay it forward, help someone else.

  • How can I remove all non alpha/space characters from a string

    Subject changed by moderator.  Please use a meaningful subject in future.
    Hi all,
    Can anyone tell me.
    how to get only alphabets & spaces from the string..
    suppose..
    raj*&{]afhajk ajkf_+#fkh jah jka7767jk hhha
    I need only
    rajafhajk ajkf fkh jah jkajk hhha
    thanks..
    Rajeev
    Edited by: Matt on Feb 17, 2009 3:36 PM

    This will work.
    CONSTANTS:
      sm2big(52) VALUE
        'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'.
    DATA:
      str_out(60),
      str_in(60) VALUE
      'raj*&{]afhajk ajkf_+^#^fkh jah jka7767jk hhha',
      my_len          TYPE i,
      pos1            TYPE i,
      pos2            TYPE i.
    START-OF-SELECTION.
      COMPUTE my_len = strlen( str_in ).
      CLEAR pos1.
      CLEAR pos2.
      WHILE pos1 LT my_len.
        IF str_in+pos1(1) co sm2big
        OR str_in+pos1(1) EQ ' '.
          str_out+pos2(1) = str_in+pos1(1).
          pos2 = pos2 + 1.
        ENDIF.
        pos1 = pos1 + 1.
      ENDWHILE.
      WRITE:/ 'String In', str_in.
      WRITE:/ 'String Out', str_out.
    and the output
    String In      raj*&{]afhajk ajkf_+^#^fkh jah jka7767jk hhha
    String Out   rajafhajk ajkffkh jah jkajk hhha            

  • My iTouch is being recognized as a digital camera and cant take out my music from it.

    i have an iphone and an ITouch and also a Ipod nano and and i just got a brand new computer cause my old 1 died. i still have music in my ipod iTouch and iPhone. i want to fill my new laptop with music. but since my iTouch and iPhone are both being read as a digital camera i can only take out photos from both. witch right now i dont care about the photos. my iPod nano on the other hand is being read as a storage device meaning i can take out the music out of the nano. i want to make it so i can also take out my misic from my iTouch and iPhone. in need of assistance. tried a bunch of methods but im tired of it. im im going to need professional help.

    - It is normal and expected for the iPod to be seen as a camera
    - What do you mean " when I put it in hard disk mode"?  iPod touches do not have a disk mode.
    - Does the iPod show in iTunes?  If not try:
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows

  • How to trim spaces from string in BMM layer?

    Hi friends,
    I need to trim spaces from the string. can you please give me syntax with example.
    Thanks

    Hi
    I have tried the below option , but it did not work . PS_D_PERSON
    PERSON_ID is char type in the data base oracle , and it is defined as varchar on the physical layer .
    So the table is loaded with space , i am not able to remove the space using trim both
    Thanks
    Sridhar.N

  • Take and delete a String from another String

    I have original input string= 111100001111
    I need to Take for example the least 4 bits .... Output= 1111
    and to be removed from the original input string so the original input string= 11110000 
    I am trying to make a generic one but the point is that I can not delete subset that I take from the original input String.  
    How can I take and delete from a string in the same time? 
    Solved!
    Go to Solution.

    Something like this?
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Split String.png ‏13 KB

  • How to get First Occurnece of SubString from any string using SharePoint Designer Workflow in SharePoint Online 2013(Office 365)

    Hello All,
    I am facing Problem in SharePoint Designer Workflow. The Problem is that while replacing some subtstring with Space from a string which contains item like {Test, Test, Test, Test}, It replaces all items.
    Below two line we are using in Workflow.
    Can any body suggest some soultion for Finding first ouucrence of ", " so that we can replace only first value from string not all. When String values are different then getting proper values but if String values are same with comma
    seperated then it replace all values.
    Please some body help and your help will be heighly appriciable.
    Thanks in Advance.
    Thanks,
    Vivek Kumar Pandey   

    Have you tried to use Regular Expressions instead of Replace?
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Need help Take out the null values from the ResultSet and Create a XML file

    hi,
    I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
    a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
    takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
    from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
    null values to XML File. When i run the program it works alright and adds the null and not null values to
    the file. But when i pass the boolean value to take out the null values it would not take it out and adds
    the null and not null values.
    Please look at the code i am posing. I am showing step by step where its not adding the null values.
    Any help is always appreciated.
    Thanks in advance.
    ============================================================================
    Frame1 Class
    ============
    public class Frame1 extends JFrame{
    private JPanel contentPane;
    private XQuery xQuery1 = new XQuery();
    private XYLayout xYLayout1 = new XYLayout();
    public Document doc;
    private JButton jButton2 = new JButton();
    private Connection con;
    private Statement stmt;
    private ResultSetToXML rstx;
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    xQuery1.setSql("");
    xQuery1.setUrl("jdbc:odbc:SCANODBC");
    xQuery1.setUserName("SYSDBA");
    xQuery1.setPassword("masterkey");
    xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
    jButton2.setText("Get XML from DB");
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(java.lang.ClassNotFoundException ex) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(ex.getMessage());
    try {
    con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
    stmt = con.createStatement();
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton2_actionPerformed(e);
    contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton2_actionPerformed(ActionEvent e) {
    try{
    OutputStream out;
    XMLOutputter outputter;
    Element root;
    org.jdom.Document doc;
    root = new Element("PINFO");
    String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
    ResultSet rs = stmt.executeQuery(query);
    /*===========This is where i am passing the ResultSet and boolean=======
    ===========value to either add the null or not null values in the file======*/
    rstx = new ResultSetToXML(rs,true);
    } //end of try
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    ======================================================================================
    ResultSetToXML class
    ====================
    public class ResultSetToXML {
    private OutputStream out;
    private Element root;
    private XMLOutputter outputter;
    private Document doc;
    // Constructor
    public ResultSetToXML(ResultSet rs, boolean checkifnull){
    try{
    String tagname="";
    String tagvalue="";
    root = new Element("pinfo");
    while (rs.next()){
    Element users = new Element("Record");
    for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
    tagname= rs.getMetaData().getColumnName(i);
    tagvalue=rs.getString(i);
    System.out.println(tagname);
    System.out.println(tagvalue);
    /*============if the boolean value is false it adds the null and not
    null value to the file =====================*/
    /*============else it checks if the value is null or the length is
    less than 0 and does the else clause in the if(checkifnull)===*/
    if(checkifnull){ 
    if((tagvalue == null) || tagvalue.length() < 0 ){
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    root.addContent(users);
    out=new FileOutputStream("c:/XMLFile.xml");
    doc = new Document(root);
    outputter = new XMLOutputter();
    outputter.output(doc,out);
    catch(IOException ioe){
    System.out.println(ioe);
    catch(SQLException sqle){

    Can someone please help me with this problem
    Thanks.

  • Take out multiple values from a db and handle them in an applet.

    I have a db with tables. I want to take out several values from them and make them visible in a JFrame (or applet).
    I dont know how to do. I have an app that connects to the db and selects the values and puts the Strings in a Vector. But now then?
    I have looked at examples that retrieve Strings but not vectors, isn't that possible?

    Hi,
    On initialization of your frame you can loop over your vector and display them.
    Now the problem is in what type of component do you want to put your data.
    I can give you an example.
    What you can do is create a String which will contain all the data from
    your vector and set that string to the component.
    Example:
    Vector data;
    String result;
    for(int i=0; i < data.size(); i++) {
    result += (String)data.elementAt(i) + "\n";
    Now you need to put the string into a component which is easy done.
    Let take a textarea component.
    JTextArea txaTest = new JTextArea();
    txtTest.setText(result);
    Now all the data will be shown in the textarea component on your frame.

  • I downloaded a word file from an inbox mail (the mail app) onto my iPad2, where is this file stored? How can I delete it if it takes up space in my iPad? Any ideas??

    I downloaded a word file from an inbox mail (the mail app) onto my iPad, where is this file stored? How can I delete it if it takes up space in my iPad? Any ideas??

    Did you ever figure out what happened?
    I had the same experience as you did, but in my case it was a big fat pdf that Mail insisted I had to download before I could view it. As happened with you, I saw the file actually downloading, and after a time I was able to view the pdf. It's been my assumption that the pdf is still somewhere on my iPad, but I have no idea where, nor how to delete it if it is still there.
    Thanks.

Maybe you are looking for

  • Re:ALV's

    Hi,           I have a ALV screen as that of VA05( list of sales order) but in this customised screen the problem is with open sales orders, there r many OPEN SALES ORDERS in VAO5 and in my customised screen there r very less How to find out where is

  • Restored from backup - Permissions errors

    OK, here goes Catastrophic xserve failure... Fixed Hardware Restored from backup Users do not have permission to open their folders within their home folders. Is there a way I can restore permissions on the home folders for each user in bulk, I reall

  • Abap memory question

    hi,guys,i did a example to test the difference between sap memory and abap memory,the result that i did program zmemory1 is : 1111  2223, but the question is when i did program zmemory2 alone,the result is the same,why i can get test2 with import sta

  • Install Best Practices- Baseline Package for ECC 6.0 EHP4

    Hi All, I know its not the right forum to post this message, but posting here as i didnt get the info from the related forum, apologies for that. Now we are planning to install SAP Best practices-Baseline Packages for ECC-EHP4 in our new server. Can

  • Only small fraction of email is now coming through

    After two days of no service, I just got a few emails to come through.  Seriously, there should be about 100+ considering the time frame, so I find it odd that only 10 emails came through just now.  Clearly I'm still missing a bunch of mail from the