Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

I have a problem with java programming

lunar_starlunar_star Posts: 3Member
I have a text files input.txt with contains

NOUN: Danh tu
VERB: Dong tu
ADJ: Tinh tu

And i have a java file ReadTextFile.java

import java.io.*;
import java.util.*;

public class ReadTextFile
{
public static void main (String [] args) throws IOException
{
File inFile = new File ("input.txt");
FileReader fReader = new FileReader (inFile);
BufferedReader bReader = new BufferedReader (fReader);
System.out.print("enter ur word search:");
System.out.flush();
DataInputStream din = new DataInputStream(System.in);
String move = null;
try
{
String line = bReader.readLine();
move = din.readLine();
while (line != null)
{


int i = line.indexOf(move.toUpperCase());
int j = line.lastIndexOf(".");
line = line.substring(i,line.length());
System.out.println (i);
line = bReader.readLine();

}
}
catch (Exception e)
{

System.exit(0);
}

}
}

i complier it and exec it
Enter ur word search: noun
NOUN: Danh tu

but when i change contain text file with:
ADJ: Tinh tu
VERB: Dong tu
NOUN: Danh tu

Enter ur word search: noun
it don't show NOUN: Danh tu
it enter and exit.

Help me it....


Sign In or Register to comment.