Home Answers Viewqa Java-Beginners Search and return lines of text file

 
 


Paola
Search and return lines of text file
0 Answer(s)      9 months ago
Posted in : Java Beginners

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









Related Pages:
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
To dump 10lakh lines from a text file to a mysql table
To dump 10lakh lines from a text file to a mysql table  I need to dump a text file datas -100000 lines into a mysql table.i'm able to dump only 152000 lines only
Search word from text file using Java
How to Search word from text file using Java In this section, we are going to search a word from the text file. For this, we have created a swing button... the user typed his/her name, it will check the name in the text file. To check
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 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
Count lines of a particular file
C:\vinod\Math_package>javac NumberOfLine.java C:\vinod\Math_package>java NumberOfLine Getting line number of a paritcular file example! Please enter file name with extension: AddTwoBigNumbers.shtml
Java Read Lines from Text File and Output in Reverse order to a Different Text File
Java Read Lines from Text File and Output in Reverse order to a Different Text File  I need to read a file that was selected by the user using... to another text file. When that is done the output values of that file need
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
how to update the text file?
how to update the text file?  my textfile with name list.txt: Rice... in my text file, if the item i entered matches with item in text file.how can i... 150 .... ....20 lines. java code: import java.io.*; import java.util.*; class
Text File I/O - DVD.java - Java Beginners
Text File I/O - DVD.java  NEED HELP PLEASE. The application should use a text file with one value on each line of the file. Each movie would use three lines: one for title; one for studio; one for year. When the application
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
display repeated lines in a file
display repeated lines in a file  i want a java program that accepts file from user and displays the repeated lines in a file
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
Java - search/find a word in a text file - Java Beginners
Java - search/find a word in a text file  Hello, I would like... to search them for a word. The word will be PASS or it can be FAIL. If PASS I want to do nothing, if FAIL, I want to record in 1 master output file, the name
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
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
Java file number of lines
Java file number of lines In this section, you will learn how to count the number of lines from the given file. Description of code: Java has provide... the lines from the file. You can see in the given example, we have created
Adding a text file - Java Beginners
Adding a text file  Hello, I need a program that will search a text file of strings representing numbers of type int and will write the largest and the smallest numbers to the screen. The file contains nothing but strings
PHP SQL Search
; PHP SQL Search is used to return the records details from the table based... helps the user to show the records details based on search text put by the user... the search text into upper case. $find = strip_tags($find) : The string
JavaScript write to text file
JavaScript write to text file  ... are going to create a file and write text into it using JavaScript. In the given example... to write the text into the created file, we have used WriteLine() method. This code
php file search
php file search  How to search file in PHP .. $dir = '/tmp
JSF Search Application Using Ajax
JSF Search Application Using Ajax      Here, Roseindia Tutorial Section provides you a JSF search application... components that one is the text box component which is for entering keywords whatever
Search string using substring
) in a directory. Search can be made using @ in the word file. So far i can find index position of @, that too in a single text file. import java.io....Search string using substring  I want to print a string by searching
JAVA: Recusrion, Binary Search
and restored to/from a file. For all the search functionalities you are to implement... one result can be returned, modify Binary Search to return all the elements...JAVA: Recusrion, Binary Search  I want to learn about Binary Search
how to sort the text file and display it in jtable
how to sort the text file and display it in jtable   my text file is: contig00001 length=586 numreads=4... ctgaggactcctcg i want to display the lines started with ">" symbol to be displayed
Lucene Search in JSP - JSP-Servlet
Lucene Search in JSP  Hello Sir, I want to Develop lucene - Search engine in Jsp page which can Search full text from XML file..through XML parser... press search button and it will search over xml file.. from (tag,values
adding Under Lines
adding Under Lines      ... add underlines. You can  any number of lines. This example gives you... make program for making line on the text. In this example we create chunk
in unix which command is used to sort the lines of data in a file in reverse order
in unix which command is used to sort the lines of data in a file in reverse order  in unix which command is used to sort the lines of data in a file... the lines of data in a file in reverse order
php search file
php search file   I wanted to write a php script to list all the files available in either folder or sub folder
Redirect to Google Search JSP
a google search in your page. Redircting to google search means the text what you... a user can enter their text for search on web through Google search. As well... to the Google search page with the result related to your query/text
create Multiple Lines
the lines. In this program we are going to tell you how you can make single  lines and how you can make multiple lines on the text in pdf files. You can make multiple lines and also make colorful lines by using
How to make a cloudy text, cloudy text, text
of you text as I have done here. Take another new file for text. Take a New File: Now take a new file to write text as I have taken here. Setting of the Text: We... How to make a cloudy text      
How to format text file? - Java Beginners
How to format text file?  I want the answer for following Query ***(Java code) How to open,read and format text file(notepad) or MS-word... String getContents(File aFile) { StringBuilder contents = new StringBuilder
JavaScript Array Binary Search
JavaScript Array Binary Search       The JavaScript Binary Search becomes very useful in case of large Arrays.  The Binary Search algorithm is used to  handle
How to perform search using AJAX?
method which simply retrieves the txt file contents but I want it search...How to perform search using AJAX?  Hi, I have following HTML code...; <td><label for="status">Search Status</td> <td><input
File download return value - Java Beginners
File download return value  How to get the return value of Open/Save/Cancel buttons in a File Download pop up using javascript
how to match the key word from a text file
how to match the key word from a text file  p>Hi all, I have the code to match the key word and from the text. I have input like this reader.txt...(devstr); data2+=devstr+"\n"; } } catch (IOException e) { } return data2
JDialog return value to JDialog ????
a search and save the result in a JLabel ...I need return this result on JLabel...JDialog return value to JDialog ????  hello all.... legend. JD1 = JDialog1 JD2 = JDialog2 JD1 open JD2......JD2 has any values, how I return
JDialog return value to JDialog ????
JDialog return value to JDialog ????  hello all.... legend. JD1 = JDialog1 JD2 = JDialog2 JD1 open JD2......JD2 has any values, how I return..., true); jd2.setVisible(true); //now I need that JD2 return a value
UITableViewCell Wrap Text - an Example
UITableViewCell Wrap Text - an Example In the example, we are discussing about the setting of UITableViewCell to warp the text in multiple lines. Though you... to break the text or wrap the text in multiple lines. We are using
How to search entry in ZipFile.
will search given entry in a zip file. The getEntry method search specific  entry in a zip file, and returns specified entry or null if it not available...How to search entry in ZipFile. In this tutorial, We will discuss the use
Search from Database In Servlet
the database according to the Search text. viewSearch.jsp display the search...Search from Database In Servlet       In this section, we have developed an Employee Search
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
search for a name
search for a name  Search for a name Write a program to accept an array of names and a name and check whether the name is present in the array. Return the count of occurrence. Use the following array as input {?Dave?, ?Ann
calling servlet from JS and return response from servlet to JS
calling servlet from JS and return response from servlet to JS  hello... task.now i want this servlet(myServlet) to return a url(eg. pages/file.jsp) to the function myFunc and the myFunc will load that file(url) on the same webpage using
Web Search
Web Search         The Web Search plugin for Eclipse allows you to search for selected text on the Web using Google, Yahoo, or Microsoft Live Search. The plugin supports
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
Search bar application
; return @"Search Results";     if(section == 0)  ...Search bar application In this tutorial, will be creating a Search screen, which have a table view with a search bar. Table should display all the data

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.