1 23 24 package com.sun.enterprise.cli.framework; 25 26 import java.io.BufferedReader ; 27 import java.io.BufferedWriter ; 28 import java.io.IOException ; 29 import java.io.Reader ; 30 import java.io.Writer ; 31 32 33 34 40 41 class Pager { 42 private BufferedReader in; 43 private BufferedWriter out; 44 private int pageLength; 45 private String line; 46 47 62 63 Pager (int lines, Reader in, Writer out) throws IOException { 64 this.in = new BufferedReader (in); 65 this.out = new BufferedWriter (out); 66 pageLength = lines; 67 nextLine(); 68 } 69 70 73 void nextPage() throws IOException { 74 for (int i = 0; (pageLength < 0 || i < pageLength) && hasNext(); i++){ 75 out.write(line); 76 out.newLine(); 77 nextLine(); 78 } 79 out.flush(); 80 } 81 82 86 boolean hasNext() { 87 return line != null; 88 } 89 90 94 private void nextLine() throws IOException { 95 line = in.readLine(); 96 } 97 98 } 99 100 | Popular Tags |