Page 3 of 3 FirstFirst 123
Results 41 to 50 of 50

Thread: dictionary

  1. #41
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by aizen92 View Post
    I printed the arrays and checked them and they were correct
    I double checked them more than once and they were correct
    No they're not; the Strings in the array read in from a file contain carriage return characters at the end; change one line:

    Java Code:
                input2.useDelimiter("\r\n");
    That should teach you not to copy and paste code supplied by someone else without understanding it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  2. #42
    aizen92 is offline Senior Member
    Join Date
    Nov 2010
    Posts
    155
    Rep Power
    4

    Default

    ohh, ok i saw the /r in the array in the debugger when clicking on the array

    i added the \r but still gave me 0 and 0

  3. #43
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by aizen92 View Post
    ohh, ok i saw the /r in the array in the debugger when clicking on the array

    i added the \r but still gave me 0 and 0
    You did something wrong then; I tried your code on an MS Windows laptop and it ran fine. I don't even understand why that line must be there, i.e. an end of line is a String separator for a Scanner so remove the entire line and try again. I'm off to a party; happy New Year.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #44
    aizen92 is offline Senior Member
    Join Date
    Nov 2010
    Posts
    155
    Rep Power
    4

    Default

    ok, ill try it on anther ide, and hope it works
    happy new year to u too

  5. #45
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    Quote Originally Posted by aizen92 View Post
    ohh, ok i saw the /r in the array in the debugger when clicking on the array

    i added the \r but still gave me 0 and 0
    if you want to get system independent newline character
    Java Code:
    String n =  System.getProperty("line.separator");

  6. #46
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by JavaHater View Post
    if you want to get system independent newline character
    Java Code:
    String n =  System.getProperty("line.separator");
    No, the OP doesn't need to set a delimeter at all; the default does fine.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #47
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    Quote Originally Posted by JosAH View Post
    No, the OP doesn't need to set a delimeter at all; the default does fine.

    Jos
    No, i saw you supplied an answer stating the use of "\r\n", that's why i suggest getting the line.separator so that he doesn't need to specify \n or \r\n, depending on whether he uses it in *nix of windows.

  8. #48
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by JavaHater View Post
    No, i saw you supplied an answer stating the use of "\r\n", that's why i suggest getting the line.separator so that he doesn't need to specify \n or \r\n, depending on whether he uses it in *nix of windows.
    No, I suggested that little hack because it was you who suggested that delimeter method which isn't needed and obfuscates the code. Starting a discussion on platform independent line terminators slows down this thread even more; setting the String separators isn't needed at all here.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #49
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    Quote Originally Posted by JosAH View Post
    No, I suggested that little hack because it was you who suggested that delimeter method which isn't needed and obfuscates the code. Starting a discussion on platform independent line terminators slows down this thread even more; setting the String separators isn't needed at all here.

    Jos
    Wrong, if you read my post carefully, I am using the scanner to read the whole file first, then using the new line as delimiter to split the whole file into the array. So each word on the line is now each element in the array. Remember OP wants to read the words from a file? I guess you didn't read enough, ya?

  10. #50
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by JavaHater View Post
    Wrong, if you read my post carefully, I am using the scanner to read the whole file first, then using the new line as delimiter to split the whole file into the array. So each word on the line is now each element in the array. Remember OP wants to read the words from a file? I guess you didn't read enough, ya?
    I was in this entire thread and have read it all but you are right about setting the delimeter to "\n" that wasn't you, I apologize for that. I don't like your tone of discussion so I'm out of this thread.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 2
    Last Post: 12-27-2010, 04:28 AM
  2. Phrases in Lucene dictionary?
    By TheShar in forum Lucene
    Replies: 0
    Last Post: 05-27-2010, 02:42 PM
  3. add dictionary
    By monir6464 in forum New To Java
    Replies: 2
    Last Post: 04-07-2008, 06:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •