Commit 65087d6e authored by RobJBarr's avatar RobJBarr
Browse files

Merge remote-tracking branch 'origin/java_extensions' into java_extensions

parents 0d6de33a deaa24c1
Pipeline #171657 passed with stages
in 16 seconds
package ic.doc.web;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.HttpOutput;
public class MarkdownResultPage implements Page {
private final String query;
private final String answer;
public MarkdownResultPage(String query, String answer) {
this.query = query;
this.answer = answer;
}
@Override
public void writeTo(HttpServletResponse resp) throws IOException {
File markdown = new File("result.md");
// Header
FileWriter writer = new FileWriter("result.md");
writer.write(query + "\n");
writer.write("======\n");
// Content
if (answer == null || answer.isEmpty()) {
writer.write("Sorry, we did not understand your query.\n");
} else {
writer.write(answer);
}
// Byte streams
InputStream inputStream = new FileInputStream(markdown);
OutputStream outputStream = new FileOutputStream(markdown);
inputStream.transferTo(outputStream);
// Remove temporary file
markdown.delete();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment