02-02-2013, 03:20 PM
Algorithm Line of Code:
Algorithm Line.doc (Size: 28.5 KB / Downloads: 24)
In our program we set the file path of the same java program to String class object ‘fileLocation’.
Step2: Buffer file so as to provide for the efficient reading of lines.
Bufferreader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
will buffer the input from the specified file.
Step3: Read a line of Code / Empty Line.
A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.
We read the line using ‘readLine’ function. The trim method is used to remove white spaces from the line. And line length is calculated.