本文整理汇总了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];
}
示例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;
}
示例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);
}
}
示例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;
}
示例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];
}
示例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);
});
}
}
示例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);
}
}
示例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");
}