KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > cli > framework > More


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.cli.framework;
25
26 import java.io.Writer JavaDoc;
27 import java.io.Reader JavaDoc;
28 import java.io.OutputStreamWriter JavaDoc;
29 import java.io.InputStreamReader JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.io.FileReader JavaDoc;
32 import java.io.FileNotFoundException JavaDoc;
33 import java.io.BufferedWriter JavaDoc;
34 import java.io.BufferedReader JavaDoc;
35
36
37 /**
38  * More.java
39  *
40  * @author <a HREF="mailto:toby.h.ferguson@sun.com">Toby H Ferguson</a>
41  * @version $Revision: 1.3 $
42  *
43  * This class provides a primitive more(1) functionality, paging
44  * through the given file, with an optional pagelength.
45  */

46
47 public class More
48 {
49   public More(int linesPerPage,
50               Reader JavaDoc src,
51               Writer JavaDoc dest,
52               Reader JavaDoc fromUser,
53               Writer JavaDoc toUser,
54               String JavaDoc promptChar,
55               String JavaDoc prompt) throws IOException JavaDoc {
56
57     loopUntilQuit(new User(fromUser, toUser, promptChar, prompt),
58                   new Pager(linesPerPage, src, dest));
59   }
60
61   private void loopUntilQuit(User user, Pager pager) throws IOException JavaDoc {
62     do {
63       pager.nextPage();
64     } while (pager.hasNext() && user.wantsToContinue());
65   }
66     
67
68 }
69
70
71
72
73
74
Popular Tags