The getDocument Method
This method is used to retrieve the rules file in a string format. For doing this action, you must connect to the Oracle Metadata Repository (MDS) or a file system, and return the rules file in a string format.
The code sample below shows how to get the file from a local file system:
private static final String RULES_FILE1 =
"file:///C:/scratch/<username>/system/mywork/linkedD/AutoAppProj/oracle/rules/credit/CreditRatingRules.rules";
public String getDocument() {
URL url = null;
try {
url = new URL(RULES_FILE1);
return readFile(url);
} catch (IOException e) {
System.err.println(e);
}
return "";
}
private String readFile(URL dictURL) {
InputStream is;
try {
is = dictURL.openStream();
} catch (IOException e) {
System.err.println(e);
return "";
}
BufferedReader reader;
try {
reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
} catch (UnsupportedEncodingException e) {
System.err.println(e);
return "";
}
String line = null;
StringBuilder stringBuilder = new StringBuilder();
String ls = System.getProperty("line.separator");
try {
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
} catch (IOException e) {
System.err.println(e);
return "";
} finally {
try {
reader.close();
} catch (IOException e) {
System.err.println(e);
}
}
return stringBuilder.toString();
}