KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tanesha > replacer > Test


1 /*
2  * libreplacer, Java library to support C-sprintf alike text formatting
3  * Copyright (C) 2002 Tanesha FTPD Project, www.tanesha.net
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 /*
20  * $Id: Test.java,v 1.4 2002/12/12 12:15:36 flower Exp $
21  */

22 package org.tanesha.replacer;
23
24 import org.tanesha.replacer.formatters.*;
25
26 public class Test {
27
28
29     public static void main(String JavaDoc [] a) {
30
31
32         String JavaDoc format = "Print >${0,-10.10}< >${0,10.10}< >${1,12}< [${3,20}] ${2,.8}%";
33
34         try {
35             System.out.println(SimplePrintf.
36                                jprintf(format, new Object JavaDoc[]{"flower",
37                                                             new Double JavaDoc(1234*12314),
38                                                             new Double JavaDoc(20.53),
39                                                             new Percent((float)0.2053, '#', '-')}));
40         }
41         catch (FormatterException fe) {
42             fe.printStackTrace();
43         }
44
45     }
46
47
48
49 }
50
Popular Tags