Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Reading txt file

  1. #1
    Junior Member
    Join Date
    Jan 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Reading txt file

    Hello everyone,

    I am creating a program what is searching a verb on a txt file with its conjugation (already written). And if I want the verb to eat, it show me the conjugation and after this it's break.But when I start the program, it doesn't show the content. Someone can help me ?


    public static int[] lireFichier(String nomFichier, String verbe)
    {
    BufferedReader br = null;
    FileReader fr = null;
    String txt;
    int [] ligne = new int[6];
    try
    {
    fr = new FileReader(nomFichier);
    br = new BufferedReader(fr);
    int i = 0;
    while((txt = br.readLine())=="To eat")
    {
    if(txt.equals(verbe))
    {
    for(i=0;i<(6);i++)
    {
    ligne[i]=Integer.parseInt(br.readLine());
    System.out.println(ligne[i]);
    }
    break;
    }
    else
    {
    br.readLine();
    }

    }
    fr.close();
    br.close();
    }
    catch(IOException e)
    {
    e.printStackTrace();
    }
    return ligne;
    }
    }
    Last edited by Abz_759; January 29th, 2024 at 02:13 PM.

Similar Threads

  1. Difficulty in creating/writing to a file (also, with reading file with data)
    By Tokugawa in forum File I/O & Other I/O Streams
    Replies: 47
    Last Post: November 19th, 2018, 06:35 PM
  2. Reading from one file and write certain strings to another file
    By Herblore in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 19th, 2014, 03:32 AM
  3. Reading a file and comparing them to an array to get the file type - java
    By tomb1992 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 4th, 2013, 06:13 PM
  4. Replies: 3
    Last Post: December 2nd, 2011, 11:53 AM
  5. Reading from a file
    By NeedzABetterSN in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 5th, 2011, 08:07 AM