hi
how can i print a sentence in different lines? like... "this is for the test of java"
so if i want to print this in the following way...
this
is
for
the
test
of
java
here is my code...
import java.io.*;
public class FileReading
{
// Main method
public static void main (String args[])
{
// Stream to read file
try
{
// Open an input stream
FileInputStream fileinput = new FileInputStream ("c:\\readfile.txt");
// Read a line of text
// System.out.println( new DataInputStream(fileinput).readLine() );
DataInputStream in = new DataInputStream(fileinput);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
// Close our input stream
fileinput.close();
}
// Catches any error conditions
catch (IOException e)
{
System.err.println ("Unable to read from file");
System.exit(-1);
}
}
}