View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program 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
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.pkg;
21  
22  import java.io.BufferedWriter;
23  import java.io.IOException;
24  import java.util.Iterator;
25  import java.util.Properties;
26  import java.util.StringTokenizer;
27  
28  /***
29   * 
30   */
31  public class PackageInfoWriter
32  {
33  
34      //--- Constant(s) ---
35  
36      //--- Data field(s) ---
37  
38      //--- Constructor(s) ---
39  
40      //--- Method(s) ---
41  
42  	public static void write(BufferedWriter out, Properties p)
43  		throws IOException
44  	{
45  		for (Iterator i = p.keySet().iterator(); i.hasNext();) {
46  			String key = (String)i.next();
47  			out.write(key + ": ");
48  
49  			String value = p.getProperty(key);
50  			if (value.length() == 0) {
51  				out.write("\n");
52  			}
53  			else {
54  				StringTokenizer t = new StringTokenizer(value, "\n", true);
55  				while (t.hasMoreTokens()) {
56  					String line = t.nextToken();
57  					if (line.equals("\n")) {
58  						out.write(" .\n");
59  					}
60  					else {
61  						out.write(line + "\n");
62  					}
63  				}
64  			}
65  		}
66  		out.write("\n");
67  		out.flush();
68  	}
69  
70  }
71