01: /*
02: * This file is part of "SnipSnap Wiki/Weblog".
03: *
04: * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
05: * All Rights Reserved.
06: *
07: * Please visit http://snipsnap.org/ for updates and contact.
08: *
09: * --LICENSE NOTICE--
10: * Licensed under the Apache License, Version 2.0 (the "License");
11: * you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software
17: * distributed under the License is distributed on an "AS IS" BASIS,
18: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: * See the License for the specific language governing permissions and
20: * limitations under the License.
21: * --LICENSE NOTICE--
22: */
23: package org.radeox.test;
24:
25: import java.io.BufferedReader;
26: import java.io.FileInputStream;
27: import java.io.InputStreamReader;
28: import java.io.PrintStream;
29: import java.io.UnsupportedEncodingException;
30:
31: import org.radeox.EngineManager;
32: import org.radeox.api.engine.RenderEngine;
33: import org.radeox.api.engine.context.RenderContext;
34: import org.radeox.engine.context.BaseRenderContext;
35:
36: public class RegexpTest {
37: public static void main(String[] args) {
38: // System.out.print("Press enter ...");
39: // try {
40: // new BufferedReader(new InputStreamReader(System.in)).readLine();
41: // } catch (IOException e) {
42: // // ignore errors
43: // }
44:
45: String file = args.length > 0 ? args[0] : "conf/wiki.txt";
46: try {
47: System.setOut(new PrintStream(System.out, true, "UTF-8"));
48: } catch (UnsupportedEncodingException e) {
49: // this should never happen
50: }
51:
52: StringBuffer tmp = new StringBuffer();
53: try {
54: BufferedReader reader = new BufferedReader(
55: new InputStreamReader(new FileInputStream(file),
56: "UTF-8"));
57: char[] buffer = new char[1024];
58: int n = 0;
59: while ((n = reader.read(buffer)) != -1) {
60: tmp.append(buffer, 0, n);
61: }
62: } catch (Exception e) {
63: System.err.println("File not found: " + e.getMessage());
64: }
65:
66: String content = tmp.toString();
67:
68: System.out.println(content);
69:
70: RenderContext context = new BaseRenderContext();
71: RenderEngine engine = EngineManager.getInstance();
72:
73: System.out.println(engine.render(content, context));
74: }
75: }
|