Search and return lines of text file
I wrote the following code, that found lines of txt file with contains certain word, but it returns only the first or the last line! (However, the System.out.println show me all the lines with the word! )
Where is the problem?!
Thank U :)
"import java.io.*;
public class SearchString {
String RL;
public String SearchString(String pathFile, String str) {
try {
BufferedReader in = new BufferedReader(new FileReader(pathFile));
String line = in.readLine();
while (line != null) {
if (line.contains(str)) {
System.out.println(line);
RL = line;
//return "Lines: "+RL; (if I write it the program copy only the first line)
}
line = in.readLine();
}
} catch (IOException ex) {
ex.printStackTrace();
}
return "Lines: "+RL;
}
} "
View Answers
Ads
Related Tutorials/Questions & Answers:
Search and return lines of text file
Search and
return lines of
text file I wrote the following code, that found
lines of txt
file with contains certain word, but it returns only...)) {
System.out.println(line);
RL = line;
//
return "
Lines: "+RL; (if I write
Read Lines from text file
Read
Lines from
text file Here's a brief desc of what my Java code does .. I'm using BufferedReader to read
lines from a
text files and split each line based on a predefined size...
Eg : If the 1st line of the
text file
Advertisements
Java search text file
Java
search text file
In this tutorial, you will learn how to
search a
text... the name of a
text file to
search for. If the name does not have a .txt extension, display an error
message. Then
search the
file in the current directory
binary search tree from text file
binary
search tree from
text file How so I go about constructing a binary
search tree from a
text file, which has letters and numbers, which must be sorted and printed in ascending order.
E.g.
Text file contents
3 apples pears
Java search word from text file
Java
search word from
text file
In this tutorial, you will learn how to
search a word from
text file and
display data related to that word. Here, we have created a
text file student.txt
which consists of id, name and marks of few
Count lines of a particular file
In this program you will learn how to read a
file and count number of
lines...
and count no of
lines in a
file.
Program first asks the user to enter.... Its reads the
file(s) and then
prints the no of
lines in each
file.
Java
delete lines in the file
delete
lines in the
file I am using a
file as Input in program...The
file contains round about 1,00,000
lines .My program after each iteration takes a data from that
file at process it.
My Question is when a particular data
delete lines in the file
delete
lines in the
file I am using a
file as Input in program...The
file contains round about 1,00,000
lines .My program after each iteration takes a data from that
file at process it.
My Question is when a particular data
delete lines in the file
delete
lines in the
file I am using a
file as Input in program...The
file contains round about 1,00,000
lines .My program after each iteration takes a data from that
file at process it.
My Question is when a particular data
Delete specific lines from text in Java
Delete specific
lines from
text in Java Hi,
beginning in java, i'm trying to delete specific line from a
text file.
Ex: i want to delete data between line 10 and 20 and between line 20 and 30.
or i want to specify line
Java read lines from file
Java read
lines from file Any code example related to Java read
lines from
file? In my project there is requirement of reading the
file line by line... of reading
file line by line in Java. Can any one share me the code for reading
text file
text file Hello can I modify the program below so that all the numerical data is stored in an external
text file,that is the data contained...=description;
this.price=price;
}
public String getCode(){
return code;
}
public
text file
text file Hi can you help me I have to modify the program below so that all the data held in it is stored in an external
text file.So there should... at the start of the program from a seperate external
text file.Thank you!
mport
Full-text Search
Full-
text Search I need a java source code to impliment a full-
text search in java web application using servlets with firebird database
Full-text Search
Full-
text Search I need a java source code to impliment a full-
text search in java web application using servlets with firebird database
Sorting text file
Sorting
text file Hello friends, i'm writing
search page for my local website. i'm storing all
file list in
text file. And also adding a value... according to begin value.
Text File having list like this:
5|
3|
can anyone
Convert Text File to PDF file
Convert
Text File to PDF file Here is the way how to covert your
Text file to PDF
File,
public class TextFileToPDF {
private static void...(inLine);
System.out.println("
Text is inserted into pdf
file
Reading a text file in java
Reading a
text file in java What is the code for Reading a
text file... in java.io.* package for reading and writing to a
file in Java.
To learn more about reading
text file in Java see the tutorial Read
File in Java.
Thanks
Convert Text File to PDF file
Convert
Text File to PDF file import java.io.BufferedReader;
import...);
System.out.println("
Text is inserted into pdf
file");
document.close... FileReader(
Input
File));
String inLine = null
Steps to read text file in pyspark
Steps to read
text file in pyspark Hi,
I am learning to write program in PySpark. I want to simply read a
text file in Pyspark and then try some code.
What are the Steps to read
text file in pyspark?
How much time it takes
uploading a text file into a database
uploading a
text file into a database how to upload a
text file... {
static
File file;
public static void main(String[] args) throws Exception {
JLabel label=new JLabel("Choose
File
Read text File
Read
text File Hi,How can I get line and keep in a String in Java
writing a text into text file at particular line number
writing a
text into
text file at particular line number Hi,
thanks for quick response, I want to insert
text at some particular line number..
after line number four my
text will display in
text file using java program
 
writing a text into text file at particular line number
writing a
text into
text file at particular line number Hi,
thanks for quick response, I want to insert
text at some particular line number..
after line number four my
text will display in
text file using java program
 
Text field save as word file
Text field save as word file Dear experts At run how to save set of
text field contains
text into single Word
file. To save in our desktop computer. Solve my problem