本文整理汇总了Java中java.io.CharArrayWriter.write方法的典型用法代码示例。如果您正苦于以下问题:Java CharArrayWriter.write方法的具体用法?Java CharArrayWriter.write怎么用?Java CharArrayWriter.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.CharArrayWriter
的用法示例。
在下文中一共展示了CharArrayWriter.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseScriptText
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private String parseScriptText(String tx) {
CharArrayWriter cw = new CharArrayWriter();
int size = tx.length();
int i = 0;
while (i < size) {
char ch = tx.charAt(i);
if (i + 2 < size && ch == '%' && tx.charAt(i + 1) == '\\'
&& tx.charAt(i + 2) == '>') {
cw.write('%');
cw.write('>');
i += 3;
} else {
cw.write(ch);
++i;
}
}
cw.close();
return cw.toString();
}
示例2: binaryReader
import java.io.CharArrayWriter; //导入方法依赖的package包/类
/**
* 读取请求流
* @param request
* @return
* @throws IOException
*/
public static String binaryReader(HttpServletRequest request) throws IOException {
String charset = request.getCharacterEncoding();
if (charset == null) {
charset = "utf-8";
}
BufferedReader in = new BufferedReader(new InputStreamReader(request
.getInputStream(), charset));
// Read the request
CharArrayWriter data = new CharArrayWriter();
char[] buf = new char[8192];
int ret;
while ((ret = in.read(buf, 0, 8192)) != -1) {
data.write(buf, 0, ret);
}
return data.toString();
}
示例3: escapeCDATA
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private String escapeCDATA(String text) {
if( text==null ) return "";
int len = text.length();
CharArrayWriter result = new CharArrayWriter(len);
for (int i=0; i<len; i++) {
if (((i+2) < len)
&& (text.charAt(i) == ']')
&& (text.charAt(i+1) == ']')
&& (text.charAt(i+2) == '>')) {
// match found
result.write(']');
result.write(']');
result.write('&');
result.write('g');
result.write('t');
result.write(';');
i += 2;
} else {
result.write(text.charAt(i));
}
}
return result.toString();
}
示例4: parseScriptText
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private String parseScriptText(String tx) {
CharArrayWriter cw = new CharArrayWriter();
int size = tx.length();
int i = 0;
while (i < size) {
char ch = tx.charAt(i);
if (i + 2 < size && ch == '%' && tx.charAt(i + 1) == '\\' && tx.charAt(i + 2) == '>') {
cw.write('%');
cw.write('>');
i += 3;
} else {
cw.write(ch);
++i;
}
}
cw.close();
return cw.toString();
}
示例5: escapeCDATA
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private String escapeCDATA(String text) {
if( text==null ) return "";
int len = text.length();
CharArrayWriter result = new CharArrayWriter(len);
for (int i=0; i<len; i++) {
if (((i+2) < len)
&& (text.charAt(i) == ']')
&& (text.charAt(i+1) == ']')
&& (text.charAt(i+2) == '>')) {
// match found
result.write(']');
result.write(']');
result.write('&');
result.write('g');
result.write('t');
result.write(';');
i += 2;
} else {
result.write(text.charAt(i));
}
}
return result.toString();
}
示例6: authenticateWithPublicKey
import java.io.CharArrayWriter; //导入方法依赖的package包/类
/**
* A convenience wrapper function which reads in a private key (PEM format, either DSA or RSA)
* and then calls <code>authenticateWithPublicKey(String, char[], String)</code>.
* <p>
* NOTE PUTTY USERS: Event though your key file may start with "-----BEGIN..."
* it is not in the expected format. You have to convert it to the OpenSSH
* key format by using the "puttygen" tool (can be downloaded from the Putty
* website). Simply load your key and then use the "Conversions/Export OpenSSH key"
* functionality to get a proper PEM file.
*
* @param user A <code>String</code> holding the username.
* @param pemFile A <code>File</code> object pointing to a file containing a DSA or RSA
* private key of the user in OpenSSH key format (PEM, you can't miss the
* "-----BEGIN DSA PRIVATE KEY-----" or "-----BEGIN RSA PRIVATE KEY-----"
* tag).
* @param password If the PEM file is encrypted then you must specify the password.
* Otherwise, this argument will be ignored and can be set to <code>null</code>.
* @return whether the connection is now authenticated.
* @throws IOException
*/
public synchronized boolean authenticateWithPublicKey(String user, File pemFile, String password)
throws IOException {
if (pemFile == null)
throw new IllegalArgumentException("pemFile argument is null");
char[] buff = new char[256];
CharArrayWriter cw = new CharArrayWriter();
FileReader fr = new FileReader(pemFile);
while (true) {
int len = fr.read(buff);
if (len < 0)
break;
cw.write(buff, 0, len);
}
fr.close();
return authenticateWithPublicKey(user, cw.toCharArray(), password);
}
示例7: 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;
}
示例8: escapeCDATA
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private String escapeCDATA(String text) {
if (text == null)
return "";
int len = text.length();
CharArrayWriter result = new CharArrayWriter(len);
for (int i = 0; i < len; i++) {
if (((i + 2) < len) && (text.charAt(i) == ']') && (text.charAt(i + 1) == ']')
&& (text.charAt(i + 2) == '>')) {
// match found
result.write(']');
result.write(']');
result.write('&');
result.write('g');
result.write('t');
result.write(';');
i += 2;
} else {
result.write(text.charAt(i));
}
}
return result.toString();
}
示例9: readTo
import java.io.CharArrayWriter; //导入方法依赖的package包/类
/** Read a maximal string until delim is encountered (which will be removed from stream).
* This impl reads only ASCII, for speed.
* Newline conventions are normalized to Unix \n.
* @return the read string, or null if the delim is not encountered before EOF.
*/
private String readTo(InputStream is, char delim) throws IOException {
if (delim == 10) {
// Not implemented - stream might have "foo\r\n" and we would
// return "foo" and leave "\n" in the stream.
throw new IOException("Not implemented"); // NOI18N
}
CharArrayWriter caw = new CharArrayWriter(100);
boolean inNewline = false;
while (true) {
int c = is.read();
if (c == -1) return null;
if (c > 126) return null;
if (c == 10 || c == 13) {
// Normalize: s/[\r\n]+/\n/g
if (inNewline) {
continue;
} else {
inNewline = true;
c = 10;
}
} else if (c < 32 && c != 9) {
// Random control character!
return null;
} else {
inNewline = false;
}
if (c == delim) {
return caw.toString();
} else {
caw.write(c);
}
}
}
示例10: getText
import java.io.CharArrayWriter; //导入方法依赖的package包/类
String getText(Mark start, Mark stop) throws JasperException {
Mark oldstart = mark();
reset(start);
CharArrayWriter caw = new CharArrayWriter();
while (!markEquals(stop)) {
caw.write(nextChar());
}
caw.close();
setCurrent(oldstart);
return caw.toString();
}
示例11: getText
import java.io.CharArrayWriter; //导入方法依赖的package包/类
String getText(Mark start, Mark stop) throws JasperException {
Mark oldstart = mark();
reset(start);
CharArrayWriter caw = new CharArrayWriter();
while (!markEquals(stop)) {
caw.write(nextChar());
}
caw.close();
setCurrent(oldstart);
return caw.toString();
}
示例12: removeQuotes
import java.io.CharArrayWriter; //导入方法依赖的package包/类
public static char[] removeQuotes(char []chars) {
CharArrayWriter caw = new CharArrayWriter();
for (int i = 0; i < chars.length; i++) {
if (chars[i] == '%' && chars[i+1] == '\\' &&
chars[i+2] == '>') {
caw.write('%');
caw.write('>');
i = i + 2;
} else {
caw.write(chars[i]);
}
}
return caw.toCharArray();
}
示例13: getText
import java.io.CharArrayWriter; //导入方法依赖的package包/类
String getText(Mark start, Mark stop) throws JasperException {
Mark oldstart = mark();
reset(start);
CharArrayWriter caw = new CharArrayWriter();
while (!stop.equals(mark()))
caw.write(nextChar());
caw.close();
reset(oldstart);
return caw.toString();
}
示例14: get
import java.io.CharArrayWriter; //导入方法依赖的package包/类
public Object get(ResultSet rs, String name) throws SQLException {
Reader stream = rs.getCharacterStream(name);
if ( stream == null ) return toExternalFormat( null );
CharArrayWriter writer = new CharArrayWriter();
for(;;) {
try {
int c = stream.read();
if ( c == -1) return toExternalFormat( writer.toCharArray() );
writer.write( c );
}
catch (IOException e) {
throw new HibernateException("Unable to read character stream from rs");
}
}
}
示例15: loadFile
import java.io.CharArrayWriter; //导入方法依赖的package包/类
private static String loadFile(String filePath, IShaderPack shaderPack, int includeLevel) throws IOException
{
if (includeLevel >= 10)
{
throw new IOException("#include depth exceeded: " + includeLevel + ", file: " + filePath);
}
else
{
++includeLevel;
InputStream inputstream = shaderPack.getResourceAsStream(filePath);
if (inputstream == null)
{
return null;
}
else
{
InputStreamReader inputstreamreader = new InputStreamReader(inputstream, "ASCII");
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
bufferedreader = resolveIncludes(bufferedreader, filePath, shaderPack, includeLevel);
CharArrayWriter chararraywriter = new CharArrayWriter();
while (true)
{
String s = bufferedreader.readLine();
if (s == null)
{
return chararraywriter.toString();
}
chararraywriter.write(s);
chararraywriter.write("\n");
}
}
}
}