本文整理汇总了Java中java.io.CharArrayWriter.size方法的典型用法代码示例。如果您正苦于以下问题:Java CharArrayWriter.size方法的具体用法?Java CharArrayWriter.size怎么用?Java CharArrayWriter.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.CharArrayWriter
的用法示例。
在下文中一共展示了CharArrayWriter.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readLine
import java.io.CharArrayWriter; //导入方法依赖的package包/类
/**
* InputStreamReader를 통해 한줄을 읽어주는 메소드.
* BufferedReader를 사용하면 buffering되는 과정에서 binary file data를
* 읽어버리는 경우가 발생할 위험이 있으므로, 직접 구현되었다.
*/
private String readLine() throws IOException
{
CharArrayWriter caw = new CharArrayWriter(40);
int buf;
while( (buf=in.read())!=-1 )
{
if( buf=='\r' )
continue;
if( buf=='\n' )
return caw.toString();
caw.write( buf );
}
if( caw.size()!=0 )
return caw.toString();
return null;
}
示例2: logEvent0
import java.io.CharArrayWriter; //导入方法依赖的package包/类
@Override
protected void logEvent0(PciAuditEvent event) {
if (!initialized) {
LOG.error("syslog audit not initialiazed");
return;
}
CharArrayWriter msg = event.toCharArrayWriter(prefix);
final int n = msg.size();
if (n > maxMessageLength) {
LOG.warn("syslog message exceeds the maximal allowed length: {} > {}, ignore it",
n, maxMessageLength);
return;
}
SyslogMessage sm = new SyslogMessage();
sm.setFacility(syslog.getDefaultFacility());
if (notEmpty(localname)) {
sm.setHostname(localname);
}
sm.setSeverity(getSeverity(event.level()));
sm.setMsg(msg);
try {
syslog.sendMessage(sm);
} catch (IOException ex) {
LOG.error("could not send syslog message: {}", ex.getMessage());
LOG.debug("could not send syslog message", ex);
}
}
示例3: toStackTrace
import java.io.CharArrayWriter; //导入方法依赖的package包/类
public static String toStackTrace(Throwable error, int cutoff) {
// default initial size is 32 chars
CharArrayWriter buffer = new CharArrayWriter(8 * 1024);
error.printStackTrace(new PrintWriter(buffer));
return buffer.size() < cutoff ? buffer.toString()
: buffer.toString().substring(0, cutoff);
}
示例4: parseTemplateText
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private void parseTemplateText(Node parent) throws JasperException {
if (!reader.hasMoreInput())
return;
CharArrayWriter ttext = new CharArrayWriter();
int ch = reader.nextChar();
while (ch != -1) {
if (ch == '<') {
// Check for "<\%"
if (reader.peekChar(0) == '\\' && reader.peekChar(1) == '%') {
ttext.write(ch);
// Swallow the \
reader.nextChar();
ttext.write(reader.nextChar());
} else {
if (ttext.size() == 0) {
ttext.write(ch);
} else {
reader.pushChar();
break;
}
}
} else if (ch == '\\' && !pageInfo.isELIgnored()) {
int next = reader.peekChar(0);
if (next == '$' || next == '#') {
ttext.write(reader.nextChar());
} else {
ttext.write(ch);
}
} else if ((ch == '$' || ch == '#' && !pageInfo.isDeferredSyntaxAllowedAsLiteral()) &&
!pageInfo.isELIgnored()) {
if (reader.peekChar(0) == '{') {
reader.pushChar();
break;
} else {
ttext.write(ch);
}
} else {
ttext.write(ch);
}
ch = reader.nextChar();
}
@SuppressWarnings("unused")
Node unused = new Node.TemplateText(ttext.toString(), start, parent);
}
示例5: parseTemplateText
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private void parseTemplateText(Node parent) throws JasperException {
if (!reader.hasMoreInput())
return;
CharArrayWriter ttext = new CharArrayWriter();
int ch = reader.nextChar();
while (ch != -1) {
if (ch == '<') {
// Check for "<\%"
if (reader.peekChar(0) == '\\' && reader.peekChar(1) == '%') {
ttext.write(ch);
// Swallow the \
reader.nextChar();
ttext.write(reader.nextChar());
} else {
if (ttext.size() == 0) {
ttext.write(ch);
} else {
reader.pushChar();
break;
}
}
} else if (ch == '\\' && !pageInfo.isELIgnored()) {
int next = reader.peekChar(0);
if (next == '$' || next == '#') {
ttext.write(reader.nextChar());
} else {
ttext.write(ch);
}
} else if ((ch == '$' || ch == '#' && !pageInfo.isDeferredSyntaxAllowedAsLiteral())
&& !pageInfo.isELIgnored()) {
if (reader.peekChar(0) == '{') {
reader.pushChar();
break;
} else {
ttext.write(ch);
}
} else {
ttext.write(ch);
}
ch = reader.nextChar();
}
@SuppressWarnings("unused")
Node unused = new Node.TemplateText(ttext.toString(), start, parent);
}