本文整理匯總了Java中com.google.common.io.CharSource.wrap方法的典型用法代碼示例。如果您正苦於以下問題:Java CharSource.wrap方法的具體用法?Java CharSource.wrap怎麽用?Java CharSource.wrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.CharSource
的用法示例。
在下文中一共展示了CharSource.wrap方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import com.google.common.io.CharSource; //導入方法依賴的package包/類
public LocalDate get() {
LocalDate res = null;
try {
CharSource charSource = CharSource.wrap(text);
String line = charSource.readFirstLine();
line = Strings.nullToEmpty(line);
Matcher matcher = REGEX.matcher(line);
if (matcher.find()) {
String data = matcher.group(0);
res = new LocalDateCsvConverter("dd/MM/yyyy").convert(data);
}
} catch (IOException e) {
}
return res;
}
示例2: computeNext
import com.google.common.io.CharSource; //導入方法依賴的package包/類
@Override
protected CharSource computeNext() {
try {
final String firstLine = reader.readLine();
// no more data - we're done
if (firstLine == null) {
return endOfData();
}
// the reader should always be starting with the split string
// note this means the file being split must begin with the split string
if (!firstLine.startsWith(splitString)) {
throw new ConcatenatedXMLException(
new IOException("Block does not start with split string " + splitString));
}
final StringBuilder data = new StringBuilder();
String line;
// we always mark our position before beginning a new line
// so that if we find the beginning of the next block, we can back up
reader.mark(maxDocBytes);
while ((line = reader.readLine()) != null) {
// beginning of next block. Back up and return what we've accumulated
if (line.startsWith(splitString)) {
reader.reset();
break;
} else {
// not done yet
data.append(line).append("\n");
reader.mark(maxDocBytes);
}
}
return CharSource.wrap(data.toString());
} catch (IOException ioe) {
throw new ConcatenatedXMLException(ioe);
}
}
示例3: ofContent
import com.google.common.io.CharSource; //導入方法依賴的package包/類
/**
* Obtains an instance of {@link CharSource} from a text variable, specified as a {@link String} object.
*
* @param content the text to create a {@link CharSource} for
* @return a new instance of {@link CharSource} with UTF-8 for charset
*/
public static CharSource ofContent(String content) {
return CharSource.wrap(content);
}
示例4: asCharSourceUtf8UsingBom
import com.google.common.io.CharSource; //導入方法依賴的package包/類
/**
* Returns a {@code CharSource} for the same bytes, converted to UTF-8 using a Byte-Order Mark if available.
*
* @return the equivalent {@code CharSource}
*/
public CharSource asCharSourceUtf8UsingBom() {
return CharSource.wrap(readUtf8UsingBom());
}
示例5: prettifyXml
import com.google.common.io.CharSource; //導入方法依賴的package包/類
/**
* Prettifies given XML String.
*
* @param xml input XML
* @return prettified input or input itself is input is not well-formed
*/
public static CharSequence prettifyXml(CharSequence xml) {
return new XmlString(CharSource.wrap(xml));
}