Read File By Line

rendra_mm2's Avatar, Join Date: Jul 2009
Go4Expert 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 ...
SyferZookie's Avatar, Join Date: Nov 2009
Light Poster
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.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
devunion's Avatar, Join Date: Sep 2008
Go4Expert Member
Take it!

Code: Java
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 SaswatPadhi; 8Nov2009 at 18:03.. Reason: Changed PHP tag to CODE tag
SyferZookie's Avatar, Join Date: Nov 2009
Light Poster
LOL! your codes are more complicated than my post