当前位置: 首页>>代码示例>>Java>>正文


Java CharSource.wrap方法代码示例

本文整理汇总了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;
}
 
开发者ID:objectos,项目名称:jabuticava,代码行数:18,代码来源:DataParser.java

示例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);
  }
}
 
开发者ID:BBN-E,项目名称:bue-common-open,代码行数:40,代码来源:ConcatenatedXMLIterableFactory.java

示例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);
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:10,代码来源:CharSources.java

示例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());
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:9,代码来源:ArrayByteSource.java

示例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));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:10,代码来源:XmlString.java


注:本文中的com.google.common.io.CharSource.wrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。