Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.nio.*;
- import java.util.*;
- public class LineByLine
- {
- public static void main(String[] args) throws IOException, InterruptedException {
- String filename="c:\\Temp\\terkepek\\20180824.dat";
- System.out.println(filename);
- withString(filename);
- //System.out.println("ENTER..."); try { System.in.read(); } catch (Exception e) { e.printStackTrace(); }
- Thread.sleep(5000);
- withStringBuffer(filename);
- //System.out.println("ENTER..."); try { System.in.read(); } catch (Exception e) { e.printStackTrace(); }
- Thread.sleep(5000);
- }
- private static void withString(String filename) {
- try {
- BufferedReader br = new BufferedReader(new FileReader(new File(filename)));
- String line = null;
- while ( ( line = br.readLine() ) != null ) {
- //System.out.println(line);
- }
- } catch (Exception e) {
- }
- }
- private static void withStringBuffer(String filename) {
- try {
- BufferedReader br = new BufferedReader(new FileReader(new File(filename)));
- StringBuilder line = new StringBuilder();
- while ( ( line.replace(0, line.length(), br.readLine().replaceAll("\\s*\\*\\s*$","") ) ) != null ) {
- //System.out.println(line.toString());
- }
- } catch (Exception e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement