1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Read File By Line

Discussion in 'Java' started by rendra_mm2, Oct 26, 2009.

  1. rendra_mm2

    rendra_mm2 New Member

    Hey advance,,, please help ...
    i wanna read a txt file by line, and get the different value

    example :
    you and me
    me and you
    you and me

    with 3 lines in that file, i want get the value just you and me and me and you

    please ... :disappoin
  2. SyferZookie

    SyferZookie New Member

    here's the codes you needed just edit it for your self
    and i know that it will help you and you can do it after i post it
     FileWriter key = new FileWriter("File");
      BufferedWriter kbd = new BufferedWriter(key);
      BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
      System.out.println("Input: ");
      String input = k.readLine();
      //kbd.write(" Zombie");
      //kbd.write(" Is there");
      //kbd.write(" NOW");
    i almost forgot
    this are to write
    just change the write to read
    if u want that ur prog will read the txt file that u made.

    thank me if i helped you
    if not its up to you :p
  3. devunion

    devunion New Member

    Take it!

    public class Reader {
        public static void main(String[] args) {
            try {
                BufferedReader br = new BufferedReader(new FileReader("file.txt"));
                List uniqueLines = new ArrayList(); 
                String line;
                while ((line = br.readLine()) != null) {
                    if (!uniqueLines.contains(line)) {
            } catch (IOException e) {
    Last edited by a moderator: Nov 8, 2009
    shabbir likes this.
  4. SyferZookie

    SyferZookie New Member

    LOL! your codes are more complicated than my post :D

Share This Page