Page 2 of 2 FirstFirst 12
Results 21 to 28 of 28
Like Tree2Likes

Thread: trouble with FILE I/O

  1. #21
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default Re: trouble with FILE I/O

    I have no idea what those values are. What happened to their id strings?

  2. #22
    dru36 is offline Member
    Join Date
    Nov 2011
    Location
    New Hampshire
    Posts
    29
    Rep Power
    0

    Default Re: trouble with FILE I/O

    Sorry,


    d2index : 4
    dindex : 0
    delWord: baa
    word : baa
    x: -1

    Now the words match, which should make everything just peachy, but it still throws an array out of bounds. I just don't see where it's coming in from.

  3. #23
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default Re: trouble with FILE I/O

    You need to print out the values of ALL the variables you are using.
    What is the value of output?
    Be sure to add a trailing char like a < to the output to show any trailing spaces.
    System.out.println("censor=" + censor +"<");

  4. #24
    dru36 is offline Member
    Join Date
    Nov 2011
    Location
    New Hampshire
    Posts
    29
    Rep Power
    0

    Default Re: trouble with FILE I/O

    It seems that the word.length is still returning as 4.

    But the problem is still the indexOf for the x.


    output: [baa baa black sheep,
    , have you any wool,
    , yes sir, yes sir, three bags full.]<
    censor: [baa, any, three]<
    o1: [baa baa black sheep,
    , have you any wool,
    , yes sir, yes sir, three bags full.]<
    c1: [baa, any, three]<
    d2index: 4 <
    dindex: 0 <
    delWord: baa<
    word: baa<
    x: -1<
    aster: ****<

  5. #25
    dru36 is offline Member
    Join Date
    Nov 2011
    Location
    New Hampshire
    Posts
    29
    Rep Power
    0

    Default Re: trouble with FILE I/O

    I just printed out the values of delWord for censors indexOf and it's returning 0 which is a good thing because that's where the value is. But I need to replace the word that's in Output not Censor.

  6. #26
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default Re: trouble with FILE I/O

    What element in the Vector output equals the contents of word?

  7. #27
    dru36 is offline Member
    Join Date
    Nov 2011
    Location
    New Hampshire
    Posts
    29
    Rep Power
    0

    Default Re: trouble with FILE I/O

    the element "baa" is the word that I'm trying to censor in this file, along with "any" and "three". I do notice that the word baa shows up twice, do you think that's the error? I'll remove baa from the vector and find out.

  8. #28
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default Re: trouble with FILE I/O

    The list or look at the elements in the Vector output and see if any off them are equal to the contents of the variable word.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Log file trouble
    By kovalensue in forum Advanced Java
    Replies: 3
    Last Post: 04-03-2011, 05:13 PM
  2. Having trouble opening and reading a txt file
    By DBaskov in forum New To Java
    Replies: 14
    Last Post: 01-29-2011, 02:55 AM
  3. Trouble with Try Catch blocks and file reading.
    By theBurgh22 in forum New To Java
    Replies: 2
    Last Post: 11-30-2010, 01:11 AM
  4. Having trouble reading external txt file to an array
    By Metastar in forum New To Java
    Replies: 18
    Last Post: 07-21-2010, 11:29 PM
  5. Replies: 0
    Last Post: 12-01-2008, 09:50 PM

Tags for this Thread

Posting Permissions

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