1 | /*
|
---|
2 | * Misc.java
|
---|
3 | * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
|
---|
4 | *
|
---|
5 | * This program is free software; you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation; either version 2 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
18 | */
|
---|
19 |
|
---|
20 | package org.greenstone.gsdl3.util;
|
---|
21 |
|
---|
22 | import java.util.HashMap;
|
---|
23 | import java.util.Set;
|
---|
24 | import java.util.Map;
|
---|
25 | import java.util.Iterator;
|
---|
26 | import java.util.Properties;
|
---|
27 | import java.io.InputStream;
|
---|
28 | import java.io.BufferedReader;
|
---|
29 | import java.io.InputStreamReader;
|
---|
30 | import java.io.IOException;
|
---|
31 | import java.net.HttpURLConnection;
|
---|
32 | import java.net.URL;
|
---|
33 | import java.net.URLConnection;
|
---|
34 |
|
---|
35 | /** contains miscellaneous functions */
|
---|
36 | public class Misc {
|
---|
37 |
|
---|
38 | public static void printHash(HashMap map) {
|
---|
39 | Set entries = map.entrySet();
|
---|
40 | Iterator i = entries.iterator();
|
---|
41 | while (i.hasNext()) {
|
---|
42 | Map.Entry m = (Map.Entry)i.next();
|
---|
43 | String name = (String)m.getKey();
|
---|
44 | String value = (String)m.getValue();
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | public static boolean isWindows() {
|
---|
49 | Properties props = System.getProperties();
|
---|
50 | String os_name = props.getProperty("os.name","");
|
---|
51 | if(os_name.startsWith("Windows")) {
|
---|
52 | return true;
|
---|
53 | }
|
---|
54 | return false;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public static BufferedReader makeHttpConnection(String url_string)
|
---|
58 | throws java.net.MalformedURLException, java.io.IOException {
|
---|
59 | BufferedReader reader = null;
|
---|
60 | URL url = new URL(url_string);
|
---|
61 | HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
---|
62 | InputStream input = connection.getInputStream();
|
---|
63 | reader = new BufferedReader(new InputStreamReader(input));
|
---|
64 | return reader;
|
---|
65 | }
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|