Results 1 to 4 of 4
  1. #1
    davidoudou is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default .txt manipulations

    Hi there,

    I am not used towork with .txt files... I want to do what seems to me a quite basic thing but stgle to do it..

    I have a file .txt where I have a few lines:

    file.txt
    line 1
    aaaaaaaaa
    aaa
    line 2
    bbbbbbbbbb
    bbb
    line 3
    cccccc
    ccc
    line 4
    dddddddddd
    ddd


    On the other hands, I have a tables of String table[2] =( "line 2", "line 3").

    What I want is to get from file.txt, the string between the 2 String from table ? In my example, I would like to get :
    "bbbbbbbbbb
    bbb"

    Does anyone have some doc about this ? a program ?

    Thanks in advance

    David

  2. #2
    eRaaaa is online now Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: .txt manipulations

    the Scanner class has nice methods to handle your problem, look at the api doc for that class here

  3. #3
    davidoudou is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default Re: .txt manipulations

    Thanks a lot

  4. #4
    dheaven is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Re: .txt manipulations

    Quote Originally Posted by davidoudou View Post
    Hi there,

    I am not used towork with .txt files... I want to do what seems to me a quite basic thing but stgle to do it..

    I have a file .txt where I have a few lines:

    file.txt
    line 1
    aaaaaaaaa
    aaa
    line 2
    bbbbbbbbbb
    bbb
    line 3
    cccccc
    ccc
    line 4
    dddddddddd
    ddd


    On the other hands, I have a tables of String table[2] =( "line 2", "line 3").

    What I want is to get from file.txt, the string between the 2 String from table ? In my example, I would like to get :
    "bbbbbbbbbb
    bbb"

    Does anyone have some doc about this ? a program ?

    Thanks in advance

    David
    You may also find this useful (it's an alternative to Scanner):
    Dystopian Code: Text File I/O in Java
    Dystopian Code: Text File I/O with Strings that Contain Spaces in Java

Posting Permissions

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