if (args.length >= 3) {
FileInputStream inStream = new FileInputStream(args[1]);
FileOutputStream outStream = new FileOutputStream(args[2]);
char[] wikiChars = getInputStreamAsCharArray(inStream, -1, encoding);
String wikiText = new String(wikiChars);
WikiModel wikiModel = new WikiModel(image, link);
String htmlStr = wikiModel.render(wikiText);
StringBuffer buff = new StringBuffer();
buff.append(top);
buff.append(header);
buff.append(htmlStr);
buff.append(bottom);
byte[] buffer = buff.toString().getBytes();
outStream.write(buffer);
inStream.close();
outStream.close();
} else {
// user input through console
final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String s = in.readLine();
if (s==null || s.equalsIgnoreCase("exit")) {
break;
}
WikiModel wikiModel = new WikiModel(image, link);
String htmlStr = wikiModel.render(s);
System.out.print(htmlStr);
}
in.close();
}
} catch (IOException e) {