本文整理汇总了Java中com.google.common.io.GwtWorkarounds.CharOutput类的典型用法代码示例。如果您正苦于以下问题:Java CharOutput类的具体用法?Java CharOutput怎么用?Java CharOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CharOutput类属于com.google.common.io.GwtWorkarounds包,在下文中一共展示了CharOutput类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encode
import com.google.common.io.GwtWorkarounds.CharOutput; //导入依赖的package包/类
/**
* Encodes the specified range of the specified byte array, and returns the encoded
* {@code String}.
*/
public final String encode(byte[] bytes, int off, int len) {
checkNotNull(bytes);
checkPositionIndexes(off, off + len, bytes.length);
CharOutput result = stringBuilderOutput(maxEncodedSize(len));
ByteOutput byteOutput = encodingStream(result);
try {
for (int i = 0; i < len; i++) {
byteOutput.write(bytes[off + i]);
}
byteOutput.close();
} catch (IOException impossible) {
throw new AssertionError("impossible");
}
return result.toString();
}
示例2: separatingOutput
import com.google.common.io.GwtWorkarounds.CharOutput; //导入依赖的package包/类
static CharOutput separatingOutput(
final CharOutput delegate, final String separator, final int afterEveryChars) {
checkNotNull(delegate);
checkNotNull(separator);
checkArgument(afterEveryChars > 0);
return new CharOutput() {
int charsUntilSeparator = afterEveryChars;
@Override
public void write(char c) throws IOException {
if (charsUntilSeparator == 0) {
for (int i = 0; i < separator.length(); i++) {
delegate.write(separator.charAt(i));
}
charsUntilSeparator = afterEveryChars;
}
delegate.write(c);
charsUntilSeparator--;
}
@Override
public void flush() throws IOException {
delegate.flush();
}
@Override
public void close() throws IOException {
delegate.close();
}
};
}
示例3: encodingStream
import com.google.common.io.GwtWorkarounds.CharOutput; //导入依赖的package包/类
@Override
ByteOutput encodingStream(final CharOutput output) {
return delegate.encodingStream(separatingOutput(output, separator, afterEveryChars));
}