forked from I2P_Developers/i2p.i2p
* load clientApp.* lines from clients.config by default, falling back on
reading the router's props only if that file doesn't exist. * by default, only log CRIT messages to the screen (the rest are sent to the log file). this will be useful with the upcoming service controller * refactor a common Properties helper to DataHelper.loadProps
This commit is contained in:
@ -9,10 +9,15 @@ package net.i2p.data;
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
@ -129,6 +134,31 @@ public class DataHelper {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* A more efficient Properties.load
|
||||
*
|
||||
*/
|
||||
public static void loadProps(Properties props, File file) throws IOException {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(file)), 16*1024);
|
||||
String line = null;
|
||||
while ( (line = in.readLine()) != null) {
|
||||
if (line.trim().length() <= 0) continue;
|
||||
if (line.charAt(0) == '#') continue;
|
||||
int split = line.indexOf('=');
|
||||
if (split <= 0) continue;
|
||||
String key = line.substring(0, split);
|
||||
String val = line.substring(split+1);
|
||||
if ( (key.length() > 0) && (val.length() > 0) )
|
||||
props.setProperty(key, val);
|
||||
}
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pretty print the collection
|
||||
*
|
||||
|
@ -59,7 +59,7 @@ public class LogManager {
|
||||
public final static int DEFAULT_CONSOLEBUFFERSIZE = 20;
|
||||
public final static String DEFAULT_ROTATIONLIMIT = "2";
|
||||
public final static String DEFAULT_DEFAULTLEVEL = Log.STR_ERROR;
|
||||
public final static String DEFAULT_ONSCREENLEVEL = Log.STR_ERROR;
|
||||
public final static String DEFAULT_ONSCREENLEVEL = Log.STR_CRIT;
|
||||
|
||||
private I2PAppContext _context;
|
||||
private Log _log;
|
||||
|
Reference in New Issue
Block a user