Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Read Lines from text file
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


AkshayJeet10
Read Lines from text file
0 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


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...


Advertisement
View Answers

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
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
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
Read Text file from Javascript - JSP-Servlet
Read Text file from Javascript  plz send the code How to Retrieve the data from .txt file thru Javascript? And how to find the perticular words in that file
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
Program to read the text from a file and display it on a JFrame.
Program to read the text from a file and display it on a JFrame.  import javax.swing.*; import java.io.*; import java.lang.*; import java.awt.*; class MegaViewer1 extends JFrame { JTabbedPane jtp1=new JTabbedPane
Read specific column data from text file in java
Read specific column data from text file in java  My question is if my text file contain 15 columns and i want read specific column data from that text file then what code i should do
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
Read text File
Read text File  Hi,How can I get line and keep in a String in Java
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 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 Specific Line from file Using Java
Read Specific Line from file Using Java Here we are going to read a specific line from the text file. For this we have created a for loop to read lines 1 to 10 from the text file. If the loop reached fifth line, the br.readLine() method
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.... Example of Read text File Line by Line: import java.io.*; class FileRead
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
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
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
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
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text 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
How to read text from - Java Beginners
How to read text from   How to retrieve text from the images... Does we have any function to get text over the images  Hi Friend, We are providing you a code that will set text over an image using javascript
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
Reading text from image file - Java Beginners
Reading text from image file  How Read text from image file
How to read text file to two different name array
How to read text file to two different name array   I have those numbers:12,4,9,5 numbers:19,12,1,1 how to put it in two different name array in text file to java
How to read text file to two different name array
How to read text file to two different name array   I have those numbers:12,4,9,5 numbers:19,12,1,1 how to put it in two different name array in text file to java
read excel file from Java - Java Beginners
read excel file from Java  How we read excel file data with the help of java?  Hi friend, For read more information on Java POI visit to : http://www.roseindia.net/java/poi/ Thanks
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
How to read the data in text file seperated by by ',' in java using IO Operations
How to read the data in text file seperated by by ',' in java using IO Operations  in Text file data like raju 45,56,67 ramu 46,65,78 raji 34,23,56 this is the student marks in text file.this data read and calculate
How to read a large text file line by line in java?
How to read a large text file line by line in java?  I have been assigned a work to read big text file and extract the data and save into database... memory assigned is also a limit. So, we have decided to read the text file line
 

 

 

DMCA.com