String file;
String inputResourceName;
boolean gotProp;
Properties connAttributeDefaults = null;
LocalizedResource langUtil = LocalizedResource.getInstance();
LocalizedOutput out = langUtil.getNewOutput(System.out);
// Validate arguments, check for --help.
if (util.invalidArgs(args)) {
util.Usage(out);
return;
}
// load the property file if specified
gotProp = util.getPropertyArg(args);
// get the default connection attributes
connAttributeDefaults = util.getConnAttributeArg(args);
// readjust output to derby.ui.locale and derby.ui.codeset if
// they were loaded from a property file.
langUtil.init();
out = langUtil.getNewOutput(System.out);
main.initAppUI();
file = util.getFileArg(args);
inputResourceName = util.getInputResourceNameArg(args);
if (inputResourceName != null) {
in = langUtil.getNewInput(util.getResourceAsStream(inputResourceName));
if (in == null) {
out.println(langUtil.getTextMessage("IJ_IjErroResoNo",inputResourceName));
return;
}
} else if (file == null) {
in = langUtil.getNewInput(System.in);
out.flush();
} else {
try {
in1 = new FileInputStream(file);
if (in1 != null) {
in1 = new BufferedInputStream(in1, utilMain.BUFFEREDFILESIZE);
in = langUtil.getNewInput(in1);
}
} catch (FileNotFoundException e) {
if (Boolean.getBoolean("ij.searchClassPath")) {
in = langUtil.getNewInput(util.getResourceAsStream(file));
}
if (in == null) {
out.println(langUtil.getTextMessage("IJ_IjErroFileNo",file));
return;
}
}
}
String outFile = util.getSystemProperty("ij.outfile");
if (outFile != null && outFile.length()>0) {
LocalizedOutput oldOut = out;
try {
out = langUtil.getNewOutput(new FileOutputStream(outFile));
}
catch (IOException ioe) {
oldOut.println(langUtil.getTextMessage("IJ_IjErroUnabTo",outFile));
}
}
// the old property name is deprecated...
String maxDisplayWidth = util.getSystemProperty("maximumDisplayWidth");
if (maxDisplayWidth==null)
maxDisplayWidth = util.getSystemProperty("ij.maximumDisplayWidth");
if (maxDisplayWidth != null && maxDisplayWidth.length() > 0) {
try {
int maxWidth = Integer.parseInt(maxDisplayWidth);
JDBCDisplayUtil.setMaxDisplayWidth(maxWidth);
}
catch (NumberFormatException nfe) {
out.println(langUtil.getTextMessage("IJ_IjErroMaxiVa", maxDisplayWidth));
}
}
/* Use the main parameter to get to
* a new Main that we can use.