Java Doc for BufferedRandomAccessFile.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » jj2000 » j2k » 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 » 6.0 JDK Modules » Java Advanced Imaging » jj2000.j2k.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   jj2000.j2k.io.BufferedRandomAccessFile

All known Subclasses:   jj2000.j2k.io.BEBufferedRandomAccessFile,
BufferedRandomAccessFile
abstract public class BufferedRandomAccessFile implements RandomAccessIO,EndianType(Code)
This class defines a Buffered Random Access File. It implements the BinaryDataInput and BinaryDataOutput interfaces so that binary data input/output can be performed. This class is abstract since no assumption is done about the byte ordering type (little Endian, big Endian). So subclasses will have to implement methods like readShort(), writeShort(), readFloat(), ...

BufferedRandomAccessFile (BRAF for short) is a RandomAccessFile containing an extra buffer. When the BRAF is accessed, it checks if the requested part of the file is in the buffer or not. If that is the case, the read/write is done on the buffer. If not, the file is uppdated to reflect the current status of the buffer and the file is then accessed for a new buffer containing the requested byte/bit.
See Also:   RandomAccessIO
See Also:   BinaryDataOutput
See Also:   BinaryDataInput
See Also:   BEBufferedRandomAccessFile



Field Summary
protected  byte[]byteBuffer
    
protected  booleanbyteBufferChanged
     Boolean keeping track of whether the byte buffer has been changed since it was read.
protected  intbyteOrdering
    
protected  booleanisEOFInBuffer
    
protected  intmaxByte
    
protected  intoffset
    
protected  intpos
    

Constructor Summary
protected  BufferedRandomAccessFile(File file, String mode, int bufferSize)
     Constructor.
protected  BufferedRandomAccessFile(File file, String mode)
     Constructor.
protected  BufferedRandomAccessFile(String name, String mode, int bufferSize)
     Constructor.
protected  BufferedRandomAccessFile(String name, String mode)
     Constructor.

Method Summary
public  voidclose()
    
final public  voidflush()
     Any data that has been buffered must be written (including buffering at the bit level), and the stream should be realigned at the byte level.
public  intgetByteOrdering()
     Returns the endianess (i.e., byte ordering) of the implementing class.
public  intgetPos()
    
public  intlength()
     Returns the current length of the stream, in bytes, taking into account any buffering.
final public  intread()
     Reads an unsigned byte of data from the stream.
final public  bytereadByte()
     Reads a signed byte (i.e., 8 bit) from the input.
final public  voidreadFully(byte b, int off, int len)
     Reads up to len bytes of data from this file into an array of bytes.
final protected  voidreadNewBuffer(int off)
     Reads a new buffer from the file.
final public  intreadUnsignedByte()
     Reads an unsigned byte (i.e., 8 bit) from the input.
public  voidseek(int off)
     Moves the current position to the given offset at which the next read or write occurs.
public  intskipBytes(int n)
     Skips n bytes from the input.
public  StringtoString()
    
final public  voidwrite(int b)
     Writes a byte to the stream.
final public  voidwrite(byte b)
     Writes a byte to the stream.
final public  voidwrite(byte[] b, int offset, int length)
     Writes aan array of bytes to the stream.
final public  voidwriteByte(int v)
     Writes the byte value of v (i.e., 8 least significant bits) to the output.

Field Detail
byteBuffer
protected byte[] byteBuffer(Code)
Buffer of bytes containing the part of the file that is currently being accessed



byteBufferChanged
protected boolean byteBufferChanged(Code)
Boolean keeping track of whether the byte buffer has been changed since it was read.



byteOrdering
protected int byteOrdering(Code)



isEOFInBuffer
protected boolean isEOFInBuffer(Code)
Whether the end of the file is in the current buffer or not



maxByte
protected int maxByte(Code)
The maximum number of bytes that can be read from the buffer



offset
protected int offset(Code)
The current offset of the buffer (which will differ from the offset of the file)



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




Constructor Detail
BufferedRandomAccessFile
protected BufferedRandomAccessFile(File file, String mode, int bufferSize) throws IOException(Code)
Constructor. Always needs a size for the buffer.
Parameters:
  file - The file associated with the buffer
Parameters:
  mode - "r" for read, "rw" or "rw+" for read and write mode ("rw+"opens the file for update whereas "rw" removes itbefore. So the 2 modes are different only if the filealready exists).
Parameters:
  bufferSize - The number of bytes to buffer
exception:
  java.io.IOException - If an I/O error ocurred.



BufferedRandomAccessFile
protected BufferedRandomAccessFile(File file, String mode) throws IOException(Code)
Constructor. Uses the default value for the byte-buffer size (512 bytes).
Parameters:
  file - The file associated with the buffer
Parameters:
  mode - "r" for read, "rw" or "rw+" for read and write mode("rw+" opens the file for update whereas "rw" removesit before. So the 2 modes are different only if thefile already exists).
exception:
  java.io.IOException - If an I/O error ocurred.



BufferedRandomAccessFile
protected BufferedRandomAccessFile(String name, String mode, int bufferSize) throws IOException(Code)
Constructor. Always needs a size for the buffer.
Parameters:
  name - The name of the file associated with the buffer
Parameters:
  mode - "r" for read, "rw" or "rw+" for read and write mode("rw+" opens the file for update whereas "rw" removesit before. So the 2 modes are different only if thefile already exists).
Parameters:
  bufferSize - The number of bytes to buffer
exception:
  java.io.IOException - If an I/O error ocurred.



BufferedRandomAccessFile
protected BufferedRandomAccessFile(String name, String mode) throws IOException(Code)
Constructor. Uses the default value for the byte-buffer size (512 bytes).
Parameters:
  name - The name of the file associated with the buffer
Parameters:
  mode - "r" for read, "rw" or "rw+" for read and write mode("rw+" opens the file for update whereas "rw" removesit before. So the 2 modes are different only if thefile already exists).
exception:
  java.io.IOException - If an I/O error ocurred.




Method Detail
close
public void close() throws IOException(Code)
Closes the buffered random access file
exception:
  java.io.IOException - If an I/O error ocurred.



flush
final public void flush() throws IOException(Code)
Any data that has been buffered must be written (including buffering at the bit level), and the stream should be realigned at the byte level.
exception:
  java.io.IOException - If an I/O error ocurred.



getByteOrdering
public int getByteOrdering()(Code)
Returns the endianess (i.e., byte ordering) of the implementing class. Note that an implementing class may implement only one type of endianness or both, which would be decided at creation time. Either EndianType.BIG_ENDIAN orEndianType.LITTLE_ENDIAN
See Also:   EndianType



getPos
public int getPos()(Code)
Returns the current offset in the file



length
public int length() throws IOException(Code)
Returns the current length of the stream, in bytes, taking into account any buffering. The length of the stream, in bytes.
exception:
  java.io.IOException - If an I/O error ocurred.



read
final public int read() throws IOException, EOFException(Code)
Reads an unsigned byte of data from the stream. Prior to reading, the stream is realigned at the byte level. The byte read.
exception:
  java.io.IOException - If an I/O error ocurred.
exception:
  java.io.EOFException - If the end of file was reached



readByte
final public byte readByte() throws EOFException, IOException(Code)
Reads a signed byte (i.e., 8 bit) from the input. Prior to reading, the input should be realigned at the byte level. The next byte-aligned signed byte (8 bit) from theinput.
exception:
  java.io.EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  java.io.IOException - If an I/O error ocurred.



readFully
final public void readFully(byte b, int off, int len) throws IOException(Code)
Reads up to len bytes of data from this file into an array of bytes. This method reads repeatedly from the stream until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.
Parameters:
  b - The buffer into which the data is to be read. It must be longenough.
Parameters:
  off - The index in 'b' where to place the first byte read.
Parameters:
  len - The number of bytes to read.
exception:
  EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  IOException - If an I/O error ocurred.



readNewBuffer
final protected void readNewBuffer(int off) throws IOException(Code)
Reads a new buffer from the file. If there has been any changes made since the buffer was read, the buffer is first written to the file.
Parameters:
  off - The offset where to move to.
exception:
  java.io.IOException - If an I/O error ocurred.



readUnsignedByte
final public int readUnsignedByte() throws EOFException, IOException(Code)
Reads an unsigned byte (i.e., 8 bit) from the input. It is returned as an int since Java does not have an unsigned byte type. Prior to reading, the input should be realigned at the byte level. The next byte-aligned unsigned byte (8 bit) from theinput, as an int.
exception:
  java.io.EOFException - If the end-of file was reached beforegetting all the necessary data.
exception:
  java.io.IOException - If an I/O error ocurred.



seek
public void seek(int off) throws IOException(Code)
Moves the current position to the given offset at which the next read or write occurs. The offset is measured from the beginning of the stream.
Parameters:
  off - The offset where to move to.
exception:
  EOFException - If in read-only and seeking beyond EOF.
exception:
  java.io.IOException - If an I/O error ocurred.



skipBytes
public int skipBytes(int n) throws EOFException, IOException(Code)
Skips n bytes from the input. Prior to skipping, the input should be realigned at the byte level.
Parameters:
  n - The number of bytes to skip
exception:
  java.io.EOFException - If the end-of file was reached beforeall the bytes could be skipped.
exception:
  java.io.IOException - If an I/O error ocurred.



toString
public String toString()(Code)
Returns a string of information about the file



write
final public void write(int b) throws IOException(Code)
Writes a byte to the stream. Prior to writing, the stream is realigned at the byte level.
Parameters:
  b - The byte to write. The lower 8 bits of b arewritten.
exception:
  java.io.IOException - If an I/O error ocurred.



write
final public void write(byte b) throws IOException(Code)
Writes a byte to the stream. Prior to writing, the stream is realigned at the byte level.
Parameters:
  b - The byte to write.
exception:
  java.io.IOException - If an I/O error ocurred.



write
final public void write(byte[] b, int offset, int length) throws IOException(Code)
Writes aan array of bytes to the stream. Prior to writing, the stream is realigned at the byte level.
Parameters:
  b - The array of bytes to write.
Parameters:
  offset - The first byte in b to write
Parameters:
  length - The number of bytes from b to write
exception:
  java.io.IOException - If an I/O error ocurred.



writeByte
final public void writeByte(int v) throws IOException(Code)
Writes the byte value of v (i.e., 8 least significant bits) to the output. Prior to writing, the output should be realigned at the byte level.

Signed or unsigned data can be written. To write a signed value just pass the byte value as an argument. To write unsigned data pass the int value as an argument (it will be automatically casted, and only the 8 least significant bits will be written).
Parameters:
  v - The value to write to the output
exception:
  java.io.IOException - If an I/O error ocurred.




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.