How can I get the number of chars in a String, without countig the Spaces?

When I do String.length(), he returns the length with Spaces, but I want the number of chars and numbers.
thx

I'm afraid you'll need to write a method of your own for that. It's very simple fortunately:public static int getLengthWithoutWhitespace(String s) {
    java.util.StringTokenizer st = new java.util.StringTokenizer(s, " \t\r\n");
    int counter = 0;
    while (st.hasMoreTokens()) counter += st.nextToken().length();
    return counter;
}This code is not tested... Here's another, a bit more reliable approach that simply passes through the characters of the string:public static int getLengthWithoutWhitespace2(String s) {
    int counter=0;
    for (int i=0; i < s.length(); i++)
        if (Character.isWhitespace(s.charAt(i))) counter++;
    return counter;
}

Similar Messages

  • How can I get rid of baseline drift in an ecg without having the dfdt or advanced signal processing toolkits?

    Hello,
    I am recieving a lot of baseline drift in my ECG signal and was wondering how I can get rid of it? I saw examples at NI .com but they used the digital filter design toolkit and the advanced sgnal processing tollkit. I have neither one of these and since I am a student and this is my senior project I have no means to get these toolkits. I tried using a high pass filter but this did not work.\
    Ray

    Ray,
    When you say that something did not work, you are not giving much information for us to use to try to help you. Did the filter not work or did it not remove the drift?
    How big is the drift, compared to the desired signal? How fast does it drift? How long are your sample sets? What are you doing with the ECG data? Looking at heart rate or analyzing a single-beat waveform for morphological changes? I think you can see that different end goals might require different approaches to baseline compensation.
    If the drift is always fairly slow, you might be able to take small segments and subtract the mean of each segment. This may result in some offset or shift at the segment boundaries, but it is very simple and can easily be implemented without requiring a special toolkit.
    Another approach is to low pass filter the ECG signal to extract an estimate of the baseline which can then be subtracted. Remember that all filters have a transient response and many will have a phase shift between the input and output.
    Lynn

  • How can we get a value in a drop down box without refreshing the page

    In my application i am having 14 drop down boxes. On selcting a particular value in a drop down box i am doing its corresponding functionality. I would like to get these values without refreshing the page each and every time i select a text box, Is it possible to get these values without refreshing the page each and every time.
    Raghu

    There is a new hype going on called AJAX. It is either that, or dumping a lot of information in javascript arrays and reading the information from there when you make selections. I would choose AJAX.

  • I have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    have an iphone4 and my husband merge his numbers with mine and i think it was deleted can you tell me how can he get his number back on his phone

    Do you possibly mean the contacts have been merged?
    If so, where are each of you syncing contacts?  A supported application on the computer? iCloud or another cloud service? An Exchange server?
    WIthout details, it's difficult to offer specific resolutions.

  • I have a DVD Acrobat Pro 9. I upgraded laptops and trying to install but the DVD is not readable. How can I get a new DVD or Download Acrobat Pro 1. The product is registered and I have the serial number. PS: Contacting Adobe on this issue is impossible..

    I have a DVD Acrobat Pro 9. I upgraded laptops and trying to install but the DVD is not readable. How can I get a new DVD or Download Acrobat Pro 1. The product is registered and I have the serial number. PS: Contacting Adobe on this issue is impossible... direct support stinks.

    Download AA 9 Pro from http://helpx.adobe.com/acrobat/kb/acrobat-downloads.html. Make a new backup for your archive. You might also take the DVD to your library to see if it is a drive problem. You might also carefully clean the DVD with water and soap (do not use anything that would scratch the surface or you have destroyed it for sure) and see if that solves the problem. This is particularly an issue if you have finger prints or other crud on the DVD. However, it could also be a bad drive as I mentioned. Hopefully the download solves your problem in any case (I would backup the download to CD and/or backup HD).

  • How can i get a number of working days in a month PL/SQL

    How can i get a number of working days in a month(excluding Saturday and Sunday) in a query in PL/SQL ?

    Please do a search before posting
    sql>
    select count(*)
    from(
    select trunc(sysdate,'month')+rownum-1 dy
    from all_objects
    where rownum <= last_day(sysdate) - trunc(sysdate,'month')+1)
    where to_char(dy,'fmday') not in ('sunday','saturday');
    COUNT(*) 
    23
    Message was edited by:
            jeneesh
    Please try yourself to change the query to one that doesn't use a subquery..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can i get iban number in transaction FDTA

    Hi Abaper,
    How can i get iban number in transaction FDTA ?
    Thanks in advance.
    Regards,
    Sourav

    This is a bit past the last activity of the thread, but I just had an idea, that requires me to get the port number in the init.
    When this particular servlet shuts down, it generates an email. Since there is more than one instance running, I figured, I would put the HOST and PORT in the email.
    The problem with saving this information from a request, is say it gets shutdown before any requests are generated.
    The email then would have the HOST portion, but the port would be null.
    Ideally there would be a way to get the port(s) that the server is listening on.
    Thanks,
    Brent Parsons

  • How can I get an album to play in order on Itunes?  The songs keep skipping all around to other albums that I did not want to listen to at that time?

    How can I get an album to play in order on Itunes?  The songs keep skipping all around to other albums that I did not want to listen to at that time?

    It sounds like you might have the shuffle button at the bottom left of the iTunes (the button with the squiggly lines).
    If that's not the case, then maybe you just need to sort your library by album by clicking the album tab at the top.
    Is your music in a playlist, or are you trying to play it from the entire library?

  • How can I get a date picker or wheel to show up in the form to make filling in a form with a lot of

    how can I get a date picker or wheel to show up in the form to make filling in a form with a lot of dates more easy?

    There is no built-in date picker available for forms created in Acrobat. There are some third-party solutions involving JavaScript (either a large collection of fields or a custom dialog) though. Also, text fields with date formatting will use a wheel type date picker on Android/iOS devices with Adobe Reader.

  • I have MAC OS X 10.6.8 (up-to-date). How can I get screen mirroring to my Apple TV to work?  The icon does not appear at top status bar..

    I have MAC OS X 10.6.8 (up-to-date). How can I get screen mirroring to my Apple TV to work?  The icon does not appear at top status bar..

    Welcome to the Apple Support Communities
    See > http://support.apple.com/kb/HT5404 AirPlay Mirroring is compatible with Mid 2011 and newer MacBooks Air, and OS X Mountain Lion.
    As you have Mac OS X Snow Leopard, you haven't got a compatible MacBook Air, so you can't use AirPlay Mirroring. However, you can use a third-party app as AirParrot to mirror the MacBook onto your Apple TV > http://www.airparrot.com

  • How can I get Notification Number from Material Document?

    Can you please tell me that how can I get Notificatin Number(QMEL-QMNUM) from Material Document(MSEG-BELNR)?
    Regards,
    Subhasish

    This question is closed but unanswered.

  • How can i get serial number on my photoshop from creative cloud

    how can I get serial number on my photoshop from creative cloud

    Creative Cloud applications aren’t licensed with a serial number, they are licensed by logging into CC.

  • How can I get authentication and authorization through OS X open directory with the Sun ZFS STOR ZS3-2

    how can I get authentication and authorization through OS X open directory with the Sun ZFS STOR ZS3-2
    I have configure NFS, I need help configuring the share that I created in the Sun ZFS STOR ZS3-2 to connect with the OS X Open Directory

    Hi,
        You may  try checking the help page for ldap configuration :
    https://<Appliance_IP>:215/wiki/index.php/Configuration:Services:LDAP
    ZFS Storage supports LDAP, NIS, AD as directory service.
    Hope Open Directory is also based on LDAP and may work in similar fashion.
    Thanks
    Nitin

  • HT201320 How can I get TRASH to show on my 5S when I slide the email to the right? I see more & Archive

    How can I get TRASH to show on my 5S when I slide the email to the left? I see more & Archive

    Hi SCAnn!
    Here is an article that can explain that feature for you:
    iOS: Understanding Gmail Archive
    http://support.apple.com/kb/ht4207
    Thanks for being a part of the Apple Support Communities!
    Regards,
    Braden

  • I had to restore my iPhone and lost a lot of music!!! How can I get it back?! No cloud appears next to the songs, just buy!

    I had to restore my iPhone and lost a lot of music!!! How can I get it back?! No cloud appears next to the songs, just buy!

    You should be storing everything on your computer and you should always backup your computer.  Have you failed to do these things?
    If so, not good, then you can redownload some iTunes purchases in some countries.  Open iTunes store, click Purchased under Quick links

Maybe you are looking for

  • Extracting data FROM SAP BW/BI TO SAP R/3 Tables

    Dear Experts,         I would like to know How to get the data from SAP BI/BW which we extracted earlier to SAP R/3 Tables. in specific I want to get the data from BW/BI to R/3 Tables again. for Ex: I have loaded data to ZFC_C25 Cube from SAP R/3 Sys

  • Pictures automatically attach to e-mail?

    Please help! I took my husband's i-phone and found a raunchy picture of him attached to an e-mail to a woman in his sent e-mail file (a Yahoo account). When I approached him about this (I think that he is cheating on me) he admitted that he took the

  • WVC54GC works fine but cannot see the movie attached to the email

    I have VISTA and WMP (windows media player) 11.0 My WVC54GC works fine, I can see the real-time video in IE, etc. BUT when I try to read the video attached in an alert email, I just see nothing in Windows Media Player. I think the video is playing fo

  • 11.6.1.629 Installation Verification Problems

    Hello!  I have two computers, Win7 64-bit and XP-Pro on a wireless network.  Today I just downloaded the newest version of Shockwave.  On its test page there is no moving animation.  So, how do I know it installed correctly?

  • How can I mount an Amazon S3 bucket so that I can use it from the Finder?

    Hi I'm looking for some tool/solution that will allow me to mount a S3 bucket, preferably a free/open-source one. Jungledisk is out of the question since it does not seem to be fully compatible with other S3 tools (the format of the uploaded files).