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



Home Answers Viewqa Java-Beginners Java - How to read a string line per line
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
Java - How to read a string line per line
2 Answer(s)      a year and 7 months ago
Posted in : Java Beginners


Java - How to read a string line per line

I am trying to find the tutorial for reading the String line per line. I have a String data, which contains many lines. What is the best way to read the big String line per line? Is there any API available in Java for this purpose?

Thanks


Advertisement
View Answers

February 26, 2013 at 8:09 AM


Hi,

The best way is to Read the data is to read it line by line. This way you can reduce the memory usage of the application and also make your application more scalable. You can use the BufferedReader or Scanner class provided by the Java API.

Using BufferedReader or Scanner class you can make your application more scalable. This way it can execute the application fast with low memory and CPU.

If you have big file you can also use the BufferedReader or Scanner class for reading the file line by line.

Following code might be used for reading the String line by line:

String[] lines = myString.split(System.getProperty("line.separator"));

Read more at:

Thanks



February 26, 2013 at 8:12 AM


Hi,

You may also use the Apache Commons IOUtils for this purpose.

Thanks



Related Tutorials/Questions & Answers:
line number in a file of entered string
line number in a file of entered string  when i entered string from console , it should show line number in a file of that string
java line chart
java line chart  Hi, I want to draw a graphic in java line chart and ? searched the documents ?n the web. I found the example codes ?n your site (http://www.roseindia.net/chartgraphs/xyline-chart.shtml) and tr?ed ?n my
Advertisements
nio read file line by line
nio read file line by line  Is there any way to read file line by line using the Java nio package? How to use the nio classes to read file line... the BufferedReader class. Check the tutorial Java Read File Line by Line - Java
line length in java - Java Beginners
line length in java  Write a program that asks the user to enter two words. The program then prints out both words on one line. The words will be separated by enough dots so that the total line length is 30  Hi friend
Making XY line chart with string and double axis
Making XY line chart with string and double axis  Good evening everybody So i'm trying to make a XYLine chart with JFreechart. The data comes from 2... into the dataset. The horizontal axis are going to be represented by a string (showing day
Line Graphs in java - Java Beginners
Line Graphs in java  Hi... I need to generate a graph by using the database values using java I know about the JFreeChart class... But by using... Chart { public static void main(String[] args) throws Exception { String
Multi line graph - Java Beginners
Multi line graph  Hi, I want a multi line graph on a single chart using jfree in java.... Can you please let me know the code... thanks... MultiLineChart extends ApplicationFrame { public MultiLineChart(final String title
Command line argument in java
Command line argument in java. In this section we are going to discuss about command line argument in java. Command line argument allow a user to pass... to the command line. It accept into the string argument of main method. Command
Draw a line in a JPanel with button click in Java
Draw a line in a JPanel with button click in Java  Draw a line in a JPanel with button click in Java
Java Generic program with command line argument
Java Generic program with command line argument  Implement Generic to perform arithmetic evaluation using command line argument by using Java
objective c read file line by line
objective c read file line by line  Please explain how to read files in Objective C line by line
line graph
line graph  I have developed an application and in that i have to compare 2 reports using line graph from the data taken from ms access database?please help
Java Get Last Line of File
Java Get Last Line of File     ... you in understanding Get Last Line of File in Java . For this we have a class... in  stream reader. We declare a String object name line using new string
Line Animation in Java
Line Animation in Java       In this example we are creating an animated line. The color of  line is changing alternatively. We use drawLine() to draw a line
AJAX Line
AJAX Line       AJAX Community with a blog, forum and tutorials Read full Description
Java I/O From the Command Line
() This method is used to read a line of text from the console. readLine(String...Java I/O From the Command Line In this section we will learn about the I/O from the command line in Java. Several times you can see that the programs runs
Line Number Reader Example
; readLine() method is used to read the data line by line. LineNumberReader... is used to read the data line by line. Then returns the data of a line...:\convert\rajesh\completed>java LineNumberReaderExample Line: 1: import java.io.
Draw Line in PowerPoint Presentation Using Java
Draw Line in PowerPoint Presentation Using Java       In this example we are going to create line in PowerPoint presentation using java. In this example we are going to make
Compiling and Running Java program from command line
Compiling and Running Java program from command line - Video tutorial... of compiling and running java program from command line. We have also video... command line: View more tutorials on Java
Removing Line Termination Characters from a String
Removing Line Termination Characters from a String... the string as output in the console, you will understand where the new line... symbol where the new line character was present in the string or text
Retriving data from MYSQL without line break using java
Retriving data from MYSQL without line break using java  get data without line breaking from mysql table (i.e data stored as mediumtext )using java
divide the line in to two
divide the line in to two  In| this |example |we| are| creating |an |string| object| .We| initialize| this| string |object| as| "Rajesh Kumar"|.| We| are| taking| sub| string | In above mentioned line based on the tag i want
please tell me about command line arguments in java?
please tell me about command line arguments in java?  please tell me about command line arguments in java?   Hi Friend, The command-line.../java/beginners/cmnd-line-arguments.shtml Thanks
please tell me about command line arguments in java?
please tell me about command line arguments in java?  please tell me about command line arguments in java?   Hi Friend, The command-line... take any number of command-line arguments which may be necessary for the program
COMMAND LINE ARGUMENTS
COMMAND LINE ARGUMENTS  JAVA PROGRAM TO ACCEPT 5 COMMAND LINE ARGUMENTS AND FIND THE SUM OF THAT FIVE.ALSO FIND OUT LARGEST AMONG THAT 5   ... FindSumAndLargest{ public static void main(String[] args){ int max = Integer.MIN
Line From code
Line From code  document.getElementById("demo").innerHTML=Date(); Please explain each and every word in this line
Command line arguments
Command line arguments  Please explain me what is the use of "command line arguments" and why we need to use
character as command line arguments
character as command line arguments  public class testing { public static void main(String args[]) { char a; a=args[0]; System.out.println("character is:"+a); } } what will be the above program output
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... line. Example of Java Read File: package FileHandling; import
read string - using loops in Java
read string - using loops in Java  Write a program to read a string composed of an unknown number of words, then count the number of words in the string, and Display the longest and shortest words, with first letter Uppercase
Java program to get the Command Line Arguments
Java program to get the Command Line Arguments       In java we can get the command  line... program we can use the string array variable args for holding command line
Advertisements
 

 

 

DMCA.com