Java Doc for FastBufferedInputStream.java in  » Development » FastUtil » it » unimi » dsi » fastutil » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » FastUtil » it.unimi.dsi.fastutil.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.InputStream
      it.unimi.dsi.fastutil.io.MeasurableInputStream
         it.unimi.dsi.fastutil.io.FastBufferedInputStream

FastBufferedInputStream
public class FastBufferedInputStream extends MeasurableInputStream implements RepositionableStream(Code)
Lightweight, unsynchronized, aligned input stream buffering class with , , and support.

This class provides buffering for input streams, but it does so with purposes and an internal logic that are radically different from the ones adopted in java.io.BufferedInputStream . The main features follow.


since:
   4.4

Inner Class :public static enum LineTerminator

Field Summary
final public static  EnumSet<LineTerminator>ALL_TERMINATORS
     A set containing all available line terminators.
final public static  intDEFAULT_BUFFER_SIZE
     The default size of the internal buffer in bytes (8Ki).
protected  intavail
     The number of buffer bytes available starting from FastBufferedInputStream.pos .
protected  bytebuffer
     The internal buffer.
protected  InputStreamis
     The underlying input stream.
protected  intpos
     The current position in the buffer.
protected  longreadBytes
     The number of bytes ever read (reset upon a call to FastBufferedInputStream.position(long) ). In particular, this will always represent the index (in the underlying input stream) of the first available byte in the buffer.

Constructor Summary
public  FastBufferedInputStream(InputStream is, int bufSize)
     Creates a new fast buffered input stream by wrapping a given input stream with a given buffer size.
public  FastBufferedInputStream(InputStream is)
     Creates a new fast buffered input stream by wrapping a given input stream with a buffer of FastBufferedInputStream.DEFAULT_BUFFER_SIZE bytes.

Method Summary
public  intavailable()
    
public  voidclose()
    
public  voidflush()
     Resets the internal logic of this fast buffered input stream, clearing the buffer.
public  longlength()
     Returns the length of the underlying input stream, if it is .
protected  booleannoMoreCharacters()
     Checks whether no more bytes will be returned.
public  voidposition(long newPosition)
    
public  longposition()
    
public  intread()
    
public  intread(byte b, int offset, int length)
    
public  intreadLine(byte[] array)
     Reads a line into the given byte array using .
Parameters:
  array - byte array where the next line will be stored.
public  intreadLine(byte[] array, EnumSet<LineTerminator> terminators)
     Reads a line into the given byte array.
Parameters:
  array - byte array where the next line will be stored.
Parameters:
  terminators - a set containing the line termination sequences that we wantto consider as valid.
public  intreadLine(byte[] array, int off, int len)
     Reads a line into the given byte-array fragment using .
Parameters:
  array - byte array where the next line will be stored.
Parameters:
  off - the first byte to use in array.
Parameters:
  len - the maximum number of bytes to read.
public  intreadLine(byte[] array, int off, int len, EnumSet<LineTerminator> terminators)
     Reads a line into the given byte-array fragment.

Reading lines (i.e., characters) out of a byte stream is not always sensible (methods available to that purpose in old versions of Java have been mercilessly deprecated). Nonetheless, in several situations, such as when decoding network protocols or headers known to be ASCII, it is very useful to be able to read a line from a byte stream.

This method will attempt to read the next line into array starting at off, reading at most len bytes.

public  voidreset()
     Resets the internal logic of this fast buffered input stream.
public  longskip(long n)
     Skips over and discards the given number of bytes of data from this fast buffered input stream.

Field Detail
ALL_TERMINATORS
final public static EnumSet<LineTerminator> ALL_TERMINATORS(Code)
A set containing all available line terminators.



DEFAULT_BUFFER_SIZE
final public static int DEFAULT_BUFFER_SIZE(Code)
The default size of the internal buffer in bytes (8Ki).



avail
protected int avail(Code)
The number of buffer bytes available starting from FastBufferedInputStream.pos .



buffer
protected byte buffer(Code)
The internal buffer.



is
protected InputStream is(Code)
The underlying input stream.



pos
protected int pos(Code)
The current position in the buffer.



readBytes
protected long readBytes(Code)
The number of bytes ever read (reset upon a call to FastBufferedInputStream.position(long) ). In particular, this will always represent the index (in the underlying input stream) of the first available byte in the buffer.




Constructor Detail
FastBufferedInputStream
public FastBufferedInputStream(InputStream is, int bufSize)(Code)
Creates a new fast buffered input stream by wrapping a given input stream with a given buffer size.
Parameters:
  is - an input stream to wrap.
Parameters:
  bufSize - the size in bytes of the internal buffer (greater than zero).



FastBufferedInputStream
public FastBufferedInputStream(InputStream is)(Code)
Creates a new fast buffered input stream by wrapping a given input stream with a buffer of FastBufferedInputStream.DEFAULT_BUFFER_SIZE bytes.
Parameters:
  is - an input stream to wrap.




Method Detail
available
public int available() throws IOException(Code)



close
public void close() throws IOException(Code)



flush
public void flush()(Code)
Resets the internal logic of this fast buffered input stream, clearing the buffer.

All buffering information is discarded, and the number of bytes read so far (and thus, also the ) is adjusted to reflect this fact.

This method is mainly useful for re-reading files that have been overwritten externally.




length
public long length() throws IOException(Code)
Returns the length of the underlying input stream, if it is . the length of the underlying input stream.
throws:
  UnsupportedOperationException - if the underlying input stream is not .



noMoreCharacters
protected boolean noMoreCharacters() throws IOException(Code)
Checks whether no more bytes will be returned.

This method will refill the internal buffer. true if there are no characters in the internal buffer andthe underlying reader is exhausted.




position
public void position(long newPosition) throws IOException(Code)



position
public long position() throws IOException(Code)



read
public int read() throws IOException(Code)



read
public int read(byte b, int offset, int length) throws IOException(Code)



readLine
public int readLine(byte[] array) throws IOException(Code)
Reads a line into the given byte array using .
Parameters:
  array - byte array where the next line will be stored. the number of bytes actually placed in array, or -1 at end of file.
See Also:   FastBufferedInputStream.readLine(byte[],int,int,EnumSet)



readLine
public int readLine(byte[] array, EnumSet<LineTerminator> terminators) throws IOException(Code)
Reads a line into the given byte array.
Parameters:
  array - byte array where the next line will be stored.
Parameters:
  terminators - a set containing the line termination sequences that we wantto consider as valid. the number of bytes actually placed in array, or -1 at end of file.
See Also:   FastBufferedInputStream.readLine(byte[],int,int,EnumSet)



readLine
public int readLine(byte[] array, int off, int len) throws IOException(Code)
Reads a line into the given byte-array fragment using .
Parameters:
  array - byte array where the next line will be stored.
Parameters:
  off - the first byte to use in array.
Parameters:
  len - the maximum number of bytes to read. the number of bytes actually placed in array, or -1 at end of file.
See Also:   FastBufferedInputStream.readLine(byte[],int,int,EnumSet)



readLine
public int readLine(byte[] array, int off, int len, EnumSet<LineTerminator> terminators) throws IOException(Code)
Reads a line into the given byte-array fragment.

Reading lines (i.e., characters) out of a byte stream is not always sensible (methods available to that purpose in old versions of Java have been mercilessly deprecated). Nonetheless, in several situations, such as when decoding network protocols or headers known to be ASCII, it is very useful to be able to read a line from a byte stream.

This method will attempt to read the next line into array starting at off, reading at most len bytes. The read, however, will be stopped by the end of file or when meeting a . Of course, for this operation to be sensible the encoding of the text contained in the stream, if any, must not generate spurious carriage returns or line feeds. Note that the termination detection uses a maximisation criterion, so if you specify both LineTerminator.CR and LineTerminator.CR_LF meeting a pair CR/LF will consider the whole pair a terminator.

Terminators are not copied into array or included in the returned count. The returned integer can be used to check whether the line is complete: if it is smaller than len, then more bytes might be available, but note that this method (contrarily to FastBufferedInputStream.read(byte[],int,int) ) can legitimately return zero when len is nonzero just because a terminator was found as the first character. Thus, the intended usage of this method is to call it on a given array, check whether len bytes have been read, and if so try again (possibly extending the array) until a number of read bytes strictly smaller than len (possibly, -1) is returned.

If you need to guarantee that a full line is read, use the following idiom:

 int start = off, len;
 while( ( len = readLine( array, start, array.length - start, terminators ) ) == array.length - start ) {
 start += len;
 array = ByteArrays.grow( array, array.length + 1 );
 };
 

At the end of the loop, the line will be placed in array starting at off (inclusive) and ending at start + Math.max( len, 0 ) (exclusive).
Parameters:
  array - byte array where the next line will be stored.
Parameters:
  off - the first byte to use in array.
Parameters:
  len - the maximum number of bytes to read.
Parameters:
  terminators - a set containing the line termination sequences that we wantto consider as valid. the number of bytes actually placed in array, or -1 at end of file.Note that the returned number will be len if no line termination sequence specified in terminators has been met before scanning len byte,and if also we did not meet the end of file.




reset
public void reset()(Code)
Resets the internal logic of this fast buffered input stream. FastBufferedInputStream.flush()InputStreamFastBufferedInputStream.reset()InputStream.markSupported



skip
public long skip(long n) throws IOException(Code)
Skips over and discards the given number of bytes of data from this fast buffered input stream.

As explained in the , the semantics of InputStream.skip(long) is fatally flawed. This method provides additional semantics as follows: it will skip the provided number of bytes, unless the end of file has been reached.

Additionally, if the underlying input stream is System.in this method will use repeated reads instead of invoking InputStream.skip(long) .
Parameters:
  n - the number of bytes to skip. the number of bytes actually skipped; it can be smaller than nonly if the end of file has been reached.
See Also:   InputStream.skip(long)




Methods inherited from it.unimi.dsi.fastutil.io.MeasurableInputStream
abstract public long length() throws IOException(Code)(Java Doc)
abstract public long position() throws IOException(Code)(Java Doc)

Methods inherited from java.io.InputStream
public int available() throws IOException(Code)(Java Doc)
public void close() throws IOException(Code)(Java Doc)
public synchronized void mark(int readlimit)(Code)(Java Doc)
public boolean markSupported()(Code)(Java Doc)
abstract public int read() throws IOException(Code)(Java Doc)
public int read(byte b) throws IOException(Code)(Java Doc)
public int read(byte b, int off, int len) throws IOException(Code)(Java Doc)
public synchronized void reset() throws IOException(Code)(Java Doc)
public long skip(long n) throws IOException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.