當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。