I have a problem with java programming - Programmers Heaven

Howdy, Stranger!

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

Categories

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.