use of java.io.PrintWriter in project eweb4j-framework by laiweiwei.
the class BDecoder method print.
private static void print(File f, File output) {
try {
BDecoder decoder = new BDecoder();
decoder.setRecoveryMode(false);
PrintWriter pw = new PrintWriter(new FileWriter(output));
decoder.print(pw, decoder.decodeStream(new BufferedInputStream(new FileInputStream(f))));
pw.flush();
} catch (Throwable e) {
}
}
use of java.io.PrintWriter in project eweb4j-framework by laiweiwei.
the class CommonUtil method getExceptionString.
public static String getExceptionString(Throwable e) {
if (e == null)
return "";
StringWriter strWriter = new StringWriter();
PrintWriter writer = new PrintWriter(strWriter, true);
e.printStackTrace(writer);
StringBuffer sb = strWriter.getBuffer();
String s = "cause by: \n\t" + sb.toString();
return s.replace("Caused by:", "<font color='red'>Caused by:");
}
use of java.io.PrintWriter in project Lazy by l123456789jy.
the class ClassUtils method dumpException.
public static String dumpException(Throwable e) {
StringWriter sw = new StringWriter(160);
sw.write(e.getClass().getName());
sw.write(":\n");
e.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
use of java.io.PrintWriter in project eweb4j-framework by laiweiwei.
the class ActionExecution method injectActionCxt2Pojo.
private void injectActionCxt2Pojo(ReflectUtil ru) throws Exception {
HttpServletRequest req = this.context.getRequest();
HttpServletResponse res = this.context.getResponse();
PrintWriter out = this.context.getWriter();
HttpSession session = this.context.getSession();
ActionProp actionProp = this.context.getActionProp();
QueryParams queryParams = this.context.getQueryParams();
for (String n : ru.getFieldsName()) {
Method m = ru.getSetter(n);
if (m == null)
continue;
Class<?> clazz = m.getParameterTypes()[0];
if (Context.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), this.context);
} else if (HttpServletRequest.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), req);
} else if (HttpServletResponse.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), res);
} else if (PrintWriter.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), out);
} else if (ServletOutputStream.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), this.context.getOut());
} else if (HttpSession.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), session);
} else if (ActionProp.class.isAssignableFrom(clazz)) {
if (actionProp == null)
actionProp = new ActionProp(clazz.getName());
this.context.setActionProp(actionProp);
m.invoke(ru.getObject(), actionProp);
} else if (QueryParams.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), queryParams);
} else if (Validation.class.isAssignableFrom(clazz)) {
m.invoke(ru.getObject(), this.context.getValidation());
} else {
/* 如果找不到注入的类型,则尝试从IOC容器获取 */
Object obj = IOC.getBean(n);
if (obj != null)
m.invoke(ru.getObject(), obj);
}
}
}
use of java.io.PrintWriter in project commons by twitter.
the class AbortHandler method doPost.
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
LOG.info(String.format("Received abort HTTP signal from %s (%s)", req.getRemoteAddr(), req.getRemoteHost()));
resp.setContentType("text/plain");
PrintWriter writer = resp.getWriter();
try {
writer.println("Aborting process NOW!");
writer.close();
abortListener.run();
} catch (Exception e) {
LOG.log(Level.WARNING, "Abort failed.", e);
}
}
Aggregations