2 package org
.de
.metux
.util
;
4 import java
.io
.IOException
;
6 import java
.io
.BufferedReader
;
7 import java
.io
.FileReader
;
8 import java
.io
.FileNotFoundException
;
9 import java
.io
.InputStreamReader
;
11 import java
.net
.URLConnection
;
15 public static String
load(URL url
)
18 return load(url
,false);
21 public static String
load(URL url
, boolean strip_comments
)
24 URLConnection conn
= url
.openConnection();
25 conn
.setDoOutput(true);
29 new BufferedReader(new InputStreamReader(conn
.getInputStream()));
32 while ((line
=rd
.readLine()) != null)
35 if (strip_comments
&& ((x
=line
.indexOf('#'))>-1))
36 line
= line
.substring(0,x
);
37 text
+= line
.trim()+"\n";
42 public static String
load(File filename
, boolean strip_comments
)
49 in
= new BufferedReader(new FileReader(filename
));
51 catch (FileNotFoundException e
)
58 while ((line
=in
.readLine())!=null)
63 if (strip_comments
&& ((x
=line
.indexOf('#'))>-1))
64 line
= line
.substring(0,x
);
66 text
+= line
.trim() + "\n";
72 public static String
load(Filename filename
, boolean strip_comments
)
75 BufferedReader in
= new BufferedReader(filename
.getReader());
78 while ((line
=in
.readLine())!=null)
82 if (strip_comments
&& ((x
=line
.indexOf('#'))>-1))
83 line
= line
.substring(0,x
);
84 text
+= line
.trim() + "\n";
89 public static String
load_def(Filename filename
, boolean strip_comments
, String def
)
94 return load(filename
, strip_comments
);
96 catch (FileNotFoundException e
)