" | " delimiter in Scanner ignores the '|'.

Am I using the Delimiter wrong?
import java.util.*;
import java.util.regex.*;
import java.io.*;
public class four_c
     public static void main( String[] args ) throws FileNotFoundException
          Scanner inFile = new Scanner ( new FileReader( "booklist.txt" ) ).useDelimiter( " | " );
          System.out.println( inFile.next() + inFile.next() + inFile.next() );
          inFile.close();
}The program gets its input from this file
an | example |
as | well |The program output is
eugene@eugene-laptop:~/javafiles$ java four_c
an|example

You need to escape it like this:
"\\|"It's not an ordinary String there but a regex.

Similar Messages

  • Ignoring the period in a sentence

    Hello,
    I am trying to create a code segment that goes through a sentence (input) word by word and displays all words which have an even number of letters and ignores the words with an odd number of letters. I have created a code that is able to do that. But, the only problem is that the last word in the sentence includes the punctuation (period, question mark) in it's count. Can anyone tell me how to go about fixingthat problem. Here's what I've come up with so far . . .
    public static void main (String[] args)
       Scanner scan = new Scanner (System.in);
       System.out.print("Enter a statement >");
       String sentenceIn = scan.nextLine();
       String oneWord;
       StringTokenizer st = new StringTokenizer(sentenceIn);
        while (st.hasMoreTokens())
           oneWord = st.nextToken();
           if (oneWord.length() % 2 == 0)
           System.out.println(oneWord);
    }Any help will be greatly appreciated!! Ana : )

    Hi,
    You could use a regular expression to remove the non word characters. Here's an example
              String test = "this is a test line, where ? there are some words!";
              test = test.replaceAll("\\W", " ");
              System.out.println("test = " + test);
              String[] parts = test.split("\\s");
              System.out.println("parts.lenth = " + parts.length);
              for (int i = 0; i < parts.length; i++) {
                   int length = parts.trim().length();
                   if (length > 0 && length % 2 == 0) {
                        System.out.println(parts[i]);

  • Want TV guide so can mark hrs ahead favorite ahead shows,&ignore the rest.

    I don't know where else to post this question, so here goes:
    Want online TV guide so can mark hrs ahead favorite ahead shows,&ignore the rest.
    Oh, and I mean for antenna broadcast tv. Not for cable or satellite, can't afford that.
    Is there such an online site or application for Mac, Firefox.
    Want to be able to look over a TV schedule and click on the shows interested in for the hours ahead and not have to bother even seeing (much less having to re-read) again the shows we have no interest in.
    I would like the shows I do not mark to just disappear from the schedule and see them no more that day and evening.
    Less clutter, much simpler, and a lot less re-reading.
    So frustrating to have to skim down the column for each hour and look at all those shows channels I've already looked at and know I have no interest in.
    I know, I should be able to remember (naahhhh), or write them down (naahhh). The mac is supposed to do all our work and thinkin for us these days.
    Hasn't some bright bulb already solved this problem for millions of viewerrs? Made such an online tv guide website, invented sucha application?
    I have been using zap2it, but it does not have any sucha feature.
    I have Mac, Snow Leopard, and using Firefox.
    Don't think I won't thank you, cuz
    I will.
    Forest Gump ("I'm not a smaaarrrt maaaaannnn.")
    Always very grateful.
    Snow Mac
    P.S.: New to Using Intel MacMini with SnowLeopard.

    thelnukus wrote:
    The mac is supposed to do all our work and thinkin for us these days.
    Oh, dear, then I must have a seriously defective Mac. It refuses to go to work for me, doesn't do my laundry or feed the cat. And it won't do my homework for me.

  • HT2357 So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    Fantastic!  Didn't work at first so restarted App store and tried again.  This time it asked 'ignore update'.  All gone!

  • How to create an XSD for file adaptor which will ignore the records that are not required.

    Hi All,
       I have a requirement, the Fixed Length file contains
    30013742387462382938742      82347023984623087   
    30037348237  983743  9837423098  98347 
    10108472398   98034702398409238 9838472398   09823409238
    300163527 387462398746 38746293874693746324763
    101037642873643 37438724683746837648 873648736
    200138743986493874398
    2002738469837246
    10003784629837469283746937463987469387
    I need to select only the records that startswith 3001 and 3003 which are of different types and ignore the remaining records like 1010,2001,2002,1000.
    Can any one help me on this.

    You can make use of "conditionValue" or "startsWith" attributes while designing you native XSD.
    Check this example - Native Format Builder Wizard - 11g Release 1 (11.1.1.6.3) for better understanding.

  • How to ignore the iOS 7.0.2 update on iPhone 5

    I do not wish to download the iOS 7.0.2 software update on my iPhone 5.
    How do I stop it reminding me? I no longer want a permanent red encircled 1 on my settings icon.
    Thanks for your help.

    I don't think you can get rid of it.  I'm not switching to iOS 7 either so I've learned to ignore the red encircled 1.  Good luck!

  • How do I add multiple pages from my scanner to the adobe app?

    How do I add multiple pages from my scanner to the adobe app?

    You can't do this in Reader. It must be done in Acrobat on Windows or Macintosh.

  • Firefox pops up an error message on certain pages, all other browsers work fine, how can I make firefox ignore the "error" [e2219] css init error: ReferenceError: g is not defined

    Basically I want to replace the Ajax Control Toolkit Slider in favor of the Component One Studio for iPhone Slider for better mobile/desktop consistency (the ajax slider doesn't work well with iPhone). I created a simple page that works on every browser and platform (iPhone, Android, Mac, Windows) except Firefox, which fails on every platform. I have already tried disabling all plugins (safe mode) and clearing cache, I have also tried this with different versions of Firefox on different platforms. I posted this error on the Component One forum but since this only occurs with Firefox I believe this is a Firefox issue.
    I searched for this error on the forums and Google but didn’t get any results:
    ''[e2219] css init error: ReferenceError: g is not defined''
    The console has this message:
    ''[12:05:26.954] uncaught exception: [Exception... "prompt aborted by user" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource:///components/nsPrompter.js :: openTabPrompt :: line 462" data: no]''
    You can see the error by visiting http://www.componentone.com/i/
    Visit the same URL with IE, Chrome or Safari and there is no error. If I click [OK] the page loads normally enough for me. Is there some JavaScript or CSS line I can put in the page to make Firefox ignore the error? If so that would be great because even if there is a fix put into Firefox itself there will be those millions of users out there that will not upgrade.

    A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.
    *http://forums.mozillazine.org/viewforum.php?f=25
    The helpers at that forum are more knowledgeable about web development issues.<br>
    You need to register at the MozillaZine forum site in order to post at that forum.

  • I can't sort a single column only (ignoring the next column)

    I can't sort a single column only (ignoring the next column) in NUMBERS

    Numbers sorting follows a database model in which each row is a 'record' rather than a collection of unrelated data items. When a table is sorted, the integrity of the individual records (rows) is maintained.
    If you need to sort a single column, that column (or its data) must be separated from the rest of the table.
    That can be done using copy/paste (as described above by Wayne), or by taking the column to be sorted out of the table, dropping it on the sheet to form a new, single column table, doing the sort, then returning the column to the original table.
    The 3 1/2 step process takes longer to describe than to do.
    Regards,
    Barry

  • Had an iPod touch and an iPhone on iTunes. Added another iPhone and iTunes erased/ignored the first two units. I deleted iTunes and reloaded to start over. How do I "Reverse" sync what is on my iPod touch and my first iPhone??

    Had an ipod touch and an iphone in iTunes. Spouse added their iphone and it deleted/ignored the first 2 (ipod touch and iphone). Deleted iTunes from computer, reloaded to start over. How do I "reverse" sync my iphone and ipod touch?? Do not want to lose all the info.

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software

  • Is it possible to ignore the cover page of a document when viewing two pages at a time.

    when viewing a document with two pages up at a time, I want to ignore the very first page/cover page in the document so that all subsequent pages line up correctly. I can't find how to do this, is it possible. I cannot extract or delete the first page b/c the document is protected. I don't want to modify the document in any way. This document is a catalog that has information spread across two pages. So, when the cover page is included in the two page scroll viewing option, all the corresponding pages are offset by one page. I want the cover page to be at the top, by itself and the rest of the pages to show side by side.

    Show - Page Display - tick Show Cover Page in Two Page View.
    On Fri, Aug 15, 2014 at 4:55 PM, lost in acrobat <[email protected]>

  • How to ignore the password policy in a custom workflow?

    Hi,
    We have a custom workflow which is called via SPML to provide 'Administrator Change Password' functionality in a portal.
    Our password policy sets the String Quality rules and Number of Previous Passwords that Cannot be Reused. But we like to bypass the password policy when the password administrators (who have a admin role with a capability - 'Change Password Administrator'). At least, restriction ' Number of Previous Passwords that Cannot be Reused' need to be ignored (But password need to be added to the history... cannot disable adding passwords to history).
    Please advice me how it could be achieved?
    The workflow steps:
    1. Checkout 'ChangeUserPassword' view for the user as an administrator
    2. Set the new password in the view, set true to view.savePasswordHistory
    3. Set password on the resources
    4.Checkin the view
    Thanks
    Siva

    Thanks eTech.
    My main goal is to skip the password history check (new password can't be a last used 10 passwords) when admin change password workflow is launched. As you suggested , I created a special password policy exactly as our regular password policy excluding "Number of Previous Passwords that Cannot be Reused" setting.
    Then before change the password of a user as admin, special policy is attached , password changed, and user's password policy is reverted back to regular one. The issue is, as the special policy does not enforce the password history check, the whole password history of the user is wiped out from the user object when the password is changed by admin change password workflow. We don't want this to happen.
    Please guide me whether is anyway to achieve just ignoring the password history without any other impact on user.
    Is adding passwords to user object's password history list is triggered by "Number of Previous Passwords that Cannot be Reused" setting of the password policy??
    Thanks
    Siva

  • How do I ignore the difference​s in DBMSs when reading data from a DB?

    My boss wants me to create a text parser that parses the below sentence and executes an SQL query.
    'get table field1,field2,field3,...,fieldN [where SQL conditional statements]'
    This corresponds to 'select field1, field2, field3, ..., fieldN from table where blahblah'.
    Since different DBMSs have different formats for timestamp, that sentence has to be changed for each DBMS.
    One way to ignore the differences is to make a complex text anlayzer that converts a certain type of timestamp string to one that fits each DBMS.
    But it looks ridiculous to adopt such a solution when there might be an elegant solution.
    LabVIEW DB Toolkit is not capable of concealing the differences.
    Does anybody have a better idea than I do?
    Solved!
    Go to Solution.

    I remember having an issue like this when working with an older version of an Oracle server. I was able alter the session by setting 'NLS_TIMESTAMP_FORMAT'.
    This page might be of interest; I found this when searching for 'NLS_TIMESTAMP_FORMAT'
    Database Portability: Date and Timestamp Columns
    (PS The Format Into String and Scan From String functions work nicely with the correct date format specifiers. See the link below in my signature for ISO 8601 timestamp/string conversions)
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Unable to install the scanner on the HP LaserJet Pro 200 color MFP M276nw in windows 7 64 bit

    HI 
    am unable to install   the scanner on the  HP LaserJet Pro 200 color MFP M276nw Drivers in windows 7 64 bit  , after runing the setup ,the printer will finshing the installation process and and it will show that the HP Scan and HP fax failed. 

    Hi @Chembo ,
    I see you're experiencing issues installing the printer software. I will do my best to assist you with this issue.
    I would disable all the start up programs and temporarily turn off the Antivirus Software and any Real Time Scanning in the Antivirus Software also, to see if that is causing the issue. How to use MSCONFIG . Click on the Startup tab and click Disable all, Then click the Services tab and check Hide All Microsoft Services.
    Restart the computer.
    Disconnect the USB cable from the printer.
    Run the uninstall from the CD.
    Go start, computer, right click on the CD for the printer, left click open in a new window, double click on uninstall.
    Make sure that the print spooler service is running.
    Right-click Print Spooler, and then click Properties.
    If the Startup type is set to Manual or Disabled, click the drop-down list, click Automatic, and then click Apply.
    Under Service status, click Stop and then Start, and then click OK.
    Run the installation again and don't connect the cable until prompted.
    Test the printer.
    Then you will have to go back and enable the Startup programs, Microsoft Services and turn the Antivirus Software back on again.
    If you need further assistance, just let me know.
    Have a nice day!
    Thank You.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • I have a new iMac with osx 10.8.3 i can not get my hp laserjet m1522nf scanner to work. The printer works but when in scanner mode the scanner does not show up

    I have a new iMac with osx 10.8.3 i can not get my hp laserjet m1522nf scanner to work. The printer works but when in scanner mode the scanner does not show up.I tried to install the newest hp driver for the printer but when I install the computer ca not find the printer.

    Repair permissions and restart your computer.
    Make sure you have the updated scanner drivers installed. 
    Install the gimp drivers:  http://gimp-print.sourceforge.net/MacOSX.php 
    http://support.apple.com/kb/PH11070 OS X Mountain Lion: Troubleshoot a network printer 
    http://support.apple.com/kb/PH11143 OS X Mountain Lion: Reset the printing system
    http://support.apple.com/kb/HT3669 Printer and scanner software available for download
    What to do when you can't print

Maybe you are looking for

  • IPhoto Library won't update

    I have an old iPhoto library from iPhoto 9 that won't update to iPhoto 11 and won't open. How do I fix this or can I retrieve the photos from the old library without opening it in iPhoto?

  • Why can't I log into my sidereel account

    I've asked for help about this issue a couple of weeks ago already. I have an account with sidereel. I never had problems and everything was working fine. Suddenly I can't access my account. I keep coming back in the screen where I need to sign up or

  • Build stand-alon​e applicatio​n with Global variable

    Question:    how to build a VI access a global variable into a standalone EXE file? there are multiple VIs access to one Global variable, one of the VIs need to run in background to update the Global variable, whick i built into EXE file. the rest VI

  • IPad2 got a terrible trouble with 3G network after updateing to IOS5.1.1

    Hello guys, I got a terrible trouble with 3G network after updateing to IOS 5.1.1.    Now when I turn on my cellular data, the iPad 2 can say the carrier and 3G on the left top. But when I tap the Safari, it turns to be:"PDP authentication failure".

  • CK-7W reset problem

    I have just changed my phone to a Nokia E51 and and I now need to use the bluetooth option on my CK-7W car kit. Although I was able to pair the phone with the car kit, it didnt actually work handsfree so someone suggested resetting the CK-7W by holdi