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


Java StreamHelper.getBuffered方法代码示例

本文整理汇总了Java中com.helger.commons.io.stream.StreamHelper.getBuffered方法的典型用法代码示例。如果您正苦于以下问题:Java StreamHelper.getBuffered方法的具体用法?Java StreamHelper.getBuffered怎么用?Java StreamHelper.getBuffered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.helger.commons.io.stream.StreamHelper的用法示例。


在下文中一共展示了StreamHelper.getBuffered方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: STXCharStream

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
private STXCharStream (@Nonnull final Reader aReader,
                       @Nonnegative final int nStartLine,
                       @Nonnegative final int nStartColumn,
                       @Nonnegative final int nBufferSize)
{
  ValueEnforcer.isGE0 (nBufferSize, "BufferSize");
  // Using a buffered reader gives a minimal speedup
  m_aReader = StreamHelper.getBuffered (ValueEnforcer.notNull (aReader, "Reader"));
  m_nLine = ValueEnforcer.isGE0 (nStartLine, "StartLine");
  m_nColumn = ValueEnforcer.isGE0 (nStartColumn, "StartColumn") - 1;

  m_nAvailable = nBufferSize;
  m_nBufsize = nBufferSize;
  m_aBuffer = new char [nBufferSize];
  m_aBufLine = new int [nBufferSize];
  m_aBufColumn = new int [nBufferSize];
  m_aNextCharBuf = new char [DEFAULT_BUF_SIZE];
}
 
开发者ID:phax,项目名称:ph-stx,代码行数:19,代码来源:STXCharStream.java

示例2: newBundle

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
@Override
public ResourceBundle newBundle (@Nonnull final String sBaseName,
                                 @Nonnull final Locale aLocale,
                                 @Nonnull final String sFormat,
                                 @Nonnull final ClassLoader aClassLoader,
                                 final boolean bReload) throws IOException
{
  ValueEnforcer.notNull (sBaseName, "BaseName");
  ValueEnforcer.notNull (aLocale, "Locale");
  ValueEnforcer.notNull (sFormat, "Format");
  ValueEnforcer.notNull (aClassLoader, "ClassLoader");

  // We can only handle XML
  if (sFormat.equals (FORMAT_XML))
  {
    final String sBundleName = toBundleName (sBaseName, aLocale);
    final String sResourceName = toResourceName (sBundleName, sFormat);
    final URL aResourceUrl = ClassLoaderHelper.getResource (aClassLoader, sResourceName);
    if (aResourceUrl != null)
      try (final InputStream aIS = StreamHelper.getBuffered (URLResource.getInputStream (aResourceUrl)))
      {
        return new XMLResourceBundle (aIS);
      }
  }
  return null;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:27,代码来源:XMLResourceBundleControl.java

示例3: loadProperties

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
@Nullable
public static NonBlockingProperties loadProperties (@Nonnull @WillClose final InputStream aIS)
{
  ValueEnforcer.notNull (aIS, "InputStream");

  final InputStream aBufferedIS = StreamHelper.getBuffered (aIS);
  try
  {
    final NonBlockingProperties aProps = new NonBlockingProperties ();
    aProps.load (aBufferedIS);
    return aProps;
  }
  catch (final IOException ex)
  {
    return null;
  }
  finally
  {
    StreamHelper.close (aBufferedIS);
    StreamHelper.close (aIS);
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:23,代码来源:PropertiesHelper.java

示例4: CSVReader

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
/**
 * Constructs {@link CSVReader} with supplied {@link CSVParser}.
 *
 * @param aReader
 *        the reader to an underlying CSV source.
 * @param aParser
 *        the parser to use to parse input
 * @param bKeepCR
 *        <code>true</code> to keep carriage returns in data read,
 *        <code>false</code> otherwise
 */
public CSVReader (@Nonnull @WillCloseWhenClosed final Reader aReader,
                  @Nonnull final CSVParser aParser,
                  final boolean bKeepCR)
{
  ValueEnforcer.notNull (aReader, "Reader");
  ValueEnforcer.notNull (aParser, "Parser");

  Reader aInternallyBufferedReader = StreamHelper.getBuffered (aReader);
  if (bKeepCR)
    m_aLineReader = new CSVLineReaderKeepCR (aInternallyBufferedReader);
  else
  {
    if (!(aInternallyBufferedReader instanceof NonBlockingBufferedReader))
    {
      // It is buffered, but we need it to support readLine
      aInternallyBufferedReader = new NonBlockingBufferedReader (aInternallyBufferedReader);
    }
    m_aLineReader = new CSVLineReaderNonBlockingBufferedReader ((NonBlockingBufferedReader) aInternallyBufferedReader);
  }
  m_aReader = aInternallyBufferedReader;
  m_aParser = aParser;
  m_bKeepCR = bKeepCR;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:35,代码来源:CSVReader.java

示例5: CSSCharStream

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
private CSSCharStream (@Nonnull final Reader aReader,
                       @Nonnegative final int nStartLine,
                       @Nonnegative final int nStartColumn,
                       @Nonnegative final int nBufferSize)
{
  ValueEnforcer.isGE0 (nBufferSize, "BufferSize");
  // Using a buffered reader gives a minimal speedup
  m_aReader = StreamHelper.getBuffered (ValueEnforcer.notNull (aReader, "Reader"));
  m_nLine = ValueEnforcer.isGE0 (nStartLine, "StartLine");
  m_nColumn = ValueEnforcer.isGE0 (nStartColumn, "StartColumn") - 1;

  m_nAvailable = nBufferSize;
  m_nBufsize = nBufferSize;
  m_aBuffer = new char [nBufferSize];
  m_aBufLine = new int [nBufferSize];
  m_aBufColumn = new int [nBufferSize];
  m_aNextCharBuf = new char [DEFAULT_BUF_SIZE];
}
 
开发者ID:phax,项目名称:ph-css,代码行数:19,代码来源:CSSCharStream.java

示例6: main

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
public static void main (final String [] args) throws IOException, CSSTokenizeException
{
  final File f = new File ("src/test/resources/testfiles/css30/good/pure-min.css");
  try (InputStream aIS = StreamHelper.getBuffered (FileHelper.getInputStream (f)))
  {
    new CSSTokenizer ().setDebugMode (false).tokenize (aIS, t -> {
      System.out.println (t);
    });
  }
}
 
开发者ID:phax,项目名称:ph-css,代码行数:11,代码来源:CSSTokenizer.java

示例7: getInputStreamAndCharsetFromBOM

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
/**
 * If a BOM is present in the {@link InputStream} it is read and if possible
 * the charset is automatically determined from the BOM.
 *
 * @param aIS
 *        The input stream to use. May not be <code>null</code>.
 * @return Never <code>null</code>. Always use the input stream contained in
 *         the returned object and never the one passed in as a parameter,
 *         because the returned IS is a push-back InputStream that has a
 *         couple of bytes already buffered!
 */
@Nonnull
public static InputStreamAndCharset getInputStreamAndCharsetFromBOM (@Nonnull @WillNotClose final InputStream aIS)
{
  ValueEnforcer.notNull (aIS, "InputStream");

  // Check for BOM
  final int nMaxBOMBytes = EUnicodeBOM.getMaximumByteCount ();
  final NonBlockingPushbackInputStream aPIS = new NonBlockingPushbackInputStream (StreamHelper.getBuffered (aIS),
                                                                                  nMaxBOMBytes);
  try
  {
    // Try to read as many bytes as necessary to determine all supported BOMs
    final byte [] aBOM = new byte [nMaxBOMBytes];
    final int nReadBOMBytes = aPIS.read (aBOM);
    EUnicodeBOM eBOM = null;
    Charset aDeterminedCharset = null;
    if (nReadBOMBytes > 0)
    {
      // Some byte BOMs were read - determine
      eBOM = EUnicodeBOM.getFromBytesOrNull (ArrayHelper.getCopy (aBOM, 0, nReadBOMBytes));
      if (eBOM == null)
      {
        // Unread the whole BOM
        aPIS.unread (aBOM, 0, nReadBOMBytes);
        // aDeterminedCharset stays null
      }
      else
      {
        if (s_aLogger.isDebugEnabled ())
          s_aLogger.debug ("Found " + eBOM + " on " + aIS.getClass ().getName ());

        // Unread the unnecessary parts of the BOM
        final int nBOMBytes = eBOM.getByteCount ();
        if (nBOMBytes < nReadBOMBytes)
          aPIS.unread (aBOM, nBOMBytes, nReadBOMBytes - nBOMBytes);

        // Use the Charset of the BOM - maybe null!
        aDeterminedCharset = eBOM.getCharset ();
      }
    }
    return new InputStreamAndCharset (aPIS, eBOM, aDeterminedCharset);
  }
  catch (final IOException ex)
  {
    s_aLogger.error ("Failed to determine BOM", ex);
    throw new UncheckedIOException (ex);
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:60,代码来源:CharsetHelper.java

示例8: CSSInputStream

import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
public CSSInputStream (@Nonnull final InputStream aIS)
{
  super (StreamHelper.getBuffered (aIS), 1024);
  ValueEnforcer.notNull (aIS, "InputStream");
}
 
开发者ID:phax,项目名称:ph-css,代码行数:6,代码来源:CSSInputStream.java


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