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 is as follows
ABC12345DEF3 and i need to split it based on a size like 3,5,2,2(which i'm reading from an excelsheet)
Then my output is as follows
ABC
12345
DE
F3
I need to do this for a file with 11 lines.
Here's my code
while((line = br.readLine())!= null)
{
int lineLength = line.length();
for(int k = 0;k < lineLength;k++)
{
oldArrayVal = arr[k] + oldArrayVal;
tokens[k] = line.substring(flag, oldArrayVal);
System.out.println(tokens[k]);
sizeOfToken = tokens[k].length();
flag = oldArrayVal;
}
}
br.close();
And here's the problem I'm facing.
Only the first line is being read from the text file and displays the output as desired. Unable to read the rest of the lines within the text files.
Any help would be appreciated...
View Answers
Ads
Related Tutorials/Questions & Answers:
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...
read from the
text file and displays the output as desired. Unable to
read the rest
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... to
read the whole
file in one go. So, in my case reading
file line by line is only
Advertisements
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 the first or the last line! (However, the System.out.println show me all the
lines
Read text File
Read text File Hi,How can I get line and keep in a String in Java
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
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
Read from file java
Read from file java How to
Read from file java? What is the best method for a
text file having a size of 10GB. Since i have to process the
file one line at a time so tell me the very best method.
Thank you
Read File from specified path in Java
How to
read a
file from a specified path in Java?
After learning so many... reads a
text file from specified path in Java. We will
give complete path... the
file, the program will
read text data line by line and
print on the console
Read text file in PySpark
Read text file in PySpark - How to
read a
text file in PySpark?
The PySpark... configuration
conf = SparkConf().setAppName("
read text file in pyspark")
sc... context with Spark configuration
conf = SparkConf().setAppName("
read text file
Count lines of a particular file
In this program you will learn how to
read a
file and count number of
lines
in it. This is the simple program that opens a
file and
read one line at a time
and count no of
lines in a
file.
Program first asks the user to enter
Read Property file From Jmeter
Read Property
file From Jmeter Hi,
I am running web driver script
from Jmeter,
but while reading property
file I am getting "
File Not Find Exception".
Please tell me how to
read ".properties"
file from Jmeter
Java read text file
a
text file one line at a time. It can also
be used to
read large
text files... by other program. Here we have used DataInputStream class to
read
the
text file....
Here is the video insturction "How to
read text file in Java?"
how to read a text file with scanner in java
how to
read a
text file with scanner in java Hi,
I am looking for the example code in Java for reading
text file line by line using the Scanner class.
how to
read a
text file with scanner in java?
Thanks
Hi
How to read text file in Servlets
How to
read text file in Servlets
 ...
file in servlets.
In this example we will use the input stream to
read the
text from the disk
file. The InputStreamReader class is used to
read the
file
how to read text file in jtable in netbeans7.0
how to
read text file in jtable in netbeans7.0
text file... want to displaythe above .txt
file in jtable as following format having 3 columns
contigID length size
and then display sequence like "ATGCGSA..." in
text
read from cmd syntax and open the file
read from cmd syntax and open the file i have to
read the name of the database e.g., "database.txt"
file from a cmd syntax and open it:
java FindKeys database=db.txt;minjoinrows=integer|all
how can i do
read from cmd syntax and open the file
read from cmd syntax and open the file i have to
read the name of the database e.g., "database.txt"
file from a cmd syntax and open it:
java FindKeys database=db.txt;minjoinrows=integer|all
how can i do
read from file and store using hash map
read from file and store using hash map I was stuck with a java project where I have to
read a
file with two different concepts and store them differently in hashmap. My data
file would be something like
Adults:
Name, xyz
Java read file
There are many ways to
read a
file in Java. DataInputStream class is used to
read text File line by line. BufferedReader is also used to
read a
file in Java...
BufferedReader class
read text from a character-input stream rather than
read one