java.io

Class RandomAccessFile

Implemented Interfaces:
Closeable, DataInput, DataOutput

public class RandomAccessFile
extends Object
implements DataOutput, DataInput, Closeable

Instances of this class support both reading and writing to a random access file. A random access file behaves like a large array of bytes stored in the file system. There is a kind of cursor, or index into the implied array, called the file pointer; input operations read bytes starting at the file pointer and advance the file pointer past the bytes read. If the random access file is created in read/write mode, then output operations are also available; output operations write bytes starting at the file pointer and advance the file pointer past the bytes written. Output operations that write past the current end of the implied array cause the array to be extended. The file pointer can be read by the getFilePointer method and set by the seek method.

It is generally true of all the reading routines in this class that if end-of-file is reached before the desired number of bytes has been read, an EOFException (which is a kind of IOException) is thrown. If any byte cannot be read for any reason other than end-of-file, an IOException other than EOFException is thrown. In particular, an IOException may be thrown if the stream has been closed.

Since:
JDK1.0

Constructor Summary

RandomAccessFile(File file, String mode)
Creates a random access file stream to read from, and optionally to write to, the file specified by the File argument.
RandomAccessFile(String name, String mode)
Creates a random access file stream to read from, and optionally to write to, a file with the specified name.

Method Summary

void
close()
Closes this random access file stream and releases any system resources associated with the stream.
FileChannel
getChannel()
Returns the unique FileChannel object associated with this file.
FileDescriptor
getFD()
Returns the opaque file descriptor object associated with this stream.
long
getFilePointer()
Returns the current offset in this file.
long
length()
Returns the length of this file.
int
read()
Reads a byte of data from this file.
int
read(b[] )
Reads up to b.length bytes of data from this file into an array of bytes.
int
read(b[] , int off, int len)
Reads up to len bytes of data from this file into an array of bytes.
boolean
readBoolean()
Reads a boolean from this file.
byte
readByte()
Reads a signed eight-bit value from this file.
char
readChar()
Reads a Unicode character from this file.
double
readDouble()
Reads a double from this file.
float
readFloat()
Reads a float from this file.
void
readFully(b[] )
Reads b.length bytes from this file into the byte array, starting at the current file pointer.
void
readFully(b[] , int off, int len)
Reads exactly len bytes from this file into the byte array, starting at the current file pointer.
int
readInt()
Reads a signed 32-bit integer from this file.
String
readLine()
Reads the next line of text from this file.
long
readLong()
Reads a signed 64-bit integer from this file.
short
readShort()
Reads a signed 16-bit number from this file.
String
readUTF()
Reads in a string from this file.
int
readUnsignedByte()
Reads an unsigned eight-bit number from this file.
int
readUnsignedShort()
Reads an unsigned 16-bit number from this file.
void
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
void
setLength(long newLength)
Sets the length of this file.
int
skipBytes(int n)
Attempts to skip over n bytes of input discarding the skipped bytes.
void
write(b[] )
Writes b.length bytes from the specified byte array to this file, starting at the current file pointer.
void
write(b[] , int off, int len)
Writes len bytes from the specified byte array starting at offset off to this file.
void
write(int b)
Writes the specified byte to this file.
void
writeBoolean(boolean v)
Writes a boolean to the file as a one-byte value.
void
writeByte(int v)
Writes a byte to the file as a one-byte value.
void
writeBytes(String s)
Writes the string to the file as a sequence of bytes.
void
writeChar(int v)
Writes a char to the file as a two-byte value, high byte first.
void
writeChars(String s)
Writes a string to the file as a sequence of characters.
void
writeDouble(double v)
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the file as an eight-byte quantity, high byte first.
void
writeFloat(float v)
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the file as a four-byte quantity, high byte first.
void
writeInt(int v)
Writes an int to the file as four bytes, high byte first.
void
writeLong(long v)
Writes a long to the file as eight bytes, high byte first.
void
writeShort(int v)
Writes a short to the file as two bytes, high byte first.
void
writeUTF(String str)
Writes a string to the file using modified UTF-8 encoding in a machine-independent manner.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

RandomAccessFile

public RandomAccessFile(File file,
                        String mode)
            throws FileNotFoundException
Creates a random access file stream to read from, and optionally to write to, the file specified by the File argument. A new FileDescriptor object is created to represent this file connection.

The mode argument specifies the access mode in which the file is to be opened. The permitted values and their meanings are:

Value

Meaning

"r" Open for reading only. Invoking any of the write methods of the resulting object will cause an IOException to be thrown.
"rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it.
"rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
"rwd"   Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.
The "rws" and "rwd" modes work much like the
force(boolean) method of the FileChannel class, passing arguments of true and false, respectively, except that they always apply to every I/O operation and are therefore often more efficient. If the file resides on a local storage device then when an invocation of a method of this class returns it is guaranteed that all changes made to the file by that invocation will have been written to that device. This is useful for ensuring that critical information is not lost in the event of a system crash. If the file does not reside on a local device then no such guarantee is made.

The "rwd" mode can be used to reduce the number of I/O operations performed. Using "rwd" only requires updates to the file's content to be written to storage; using "rws" requires updates to both the file's content and its metadata to be written, which generally requires at least one more low-level I/O operation.

If there is a security manager, its checkRead method is called with the pathname of the file argument as its argument to see if read access to the file is allowed. If the mode allows writing, the security manager's checkWrite method is also called with the path argument to see if write access to the file is allowed.

Parameters:
file - the file object
mode - the access mode, as described above
Throws:
IllegalArgumentException - if the mode argument is not equal to one of "r", "rw", "rws", or "rwd"
FileNotFoundException - if the mode is "r" but the given file object does not denote an existing regular file, or if the mode begins with "rw" but the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
SecurityException - if a security manager exists and its checkRead method denies read access to the file or the mode is "rw" and the security manager's checkWrite method denies write access to the file
Usages and Demos :

View More Examples of RandomAccessFile(File file,String mode)
   1:     {
   2:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   3:     
   4:       for ( String line; (line=f.readLine()) != null; )
   5:         System.out.println( line );

View Full Code Here
   1:       RandomAccessFile f;
   2:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   3:       
   4:       for ( String line; (line=f.readLine()) != null; )
   5:         System.out.println( line );

View Full Code Here
   1:     {
   2:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   3:       
   4:       for ( String line; (line=f.readLine()) != null; )
   5:         System.out.println( line );

View Full Code Here
   1:   public static void main(String args[])throws IOException{
   2:      RandomAccessFile rf=new RandomAccessFile("D:\\test.dat","rw");
   3:      for(int i=0;i<10;i++)
   4:        rf.writeLong(i*1000);

View Full Code Here
   1:   public static void main(String args[])throws IOException{
   2:     MappedByteBuffer mb=new RandomAccessFile("D:\\test.txt","rw")
   3:                         .getChannel()
   4:                         .map(FileChannel.MapMode.READ_WRITE,0,capacity);
   5:     mb.flip();

View Full Code Here

RandomAccessFile

public RandomAccessFile(String name,
                        String mode)
            throws FileNotFoundException
Creates a random access file stream to read from, and optionally to write to, a file with the specified name. A new FileDescriptor object is created to represent the connection to the file.

The mode argument specifies the access mode with which the file is to be opened. The permitted values and their meanings are as specified for the RandomAccessFile(File,String) constructor.

If there is a security manager, its checkRead method is called with the name argument as its argument to see if read access to the file is allowed. If the mode allows writing, the security manager's checkWrite method is also called with the name argument as its argument to see if write access to the file is allowed.

Parameters:
name - the system-dependent filename
mode - the access mode
Throws:
IllegalArgumentException - if the mode argument is not equal to one of "r", "rw", "rws", or "rwd"
FileNotFoundException - if the mode is "r" but the given string does not denote an existing regular file, or if the mode begins with "rw" but the given string does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file
SecurityException - if a security manager exists and its checkRead method denies read access to the file or the mode is "rw" and the security manager's checkWrite method denies write access to the file
Usages and Demos :

View More Examples of RandomAccessFile(String name,String mode)
   1:     {
   2:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   3:     
   4:       for ( String line; (line=f.readLine()) != null; )
   5:         System.out.println( line );

View Full Code Here
   1:       RandomAccessFile f;
   2:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   3:       
   4:       for ( String line; (line=f.readLine()) != null; )
   5:         System.out.println( line );

View Full Code Here
   1:     {
   2:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   3:       
   4:       for ( String line; (line=f.readLine()) != null; )
   5:         System.out.println( line );

View Full Code Here
   1:   public static void main(String args[])throws IOException{
   2:      RandomAccessFile rf=new RandomAccessFile("D:\\test.dat","rw");
   3:      for(int i=0;i<10;i++)
   4:        rf.writeLong(i*1000);

View Full Code Here
   1:   public static void main(String args[])throws IOException{
   2:     MappedByteBuffer mb=new RandomAccessFile("D:\\test.txt","rw")
   3:                         .getChannel()
   4:                         .map(FileChannel.MapMode.READ_WRITE,0,capacity);
   5:     mb.flip();

View Full Code Here

Method Details

close

public void close()
            throws IOException
Closes this random access file stream and releases any system resources associated with the stream. A closed random access file cannot perform input or output operations and cannot be reopened.

If this file has an associated channel then the channel is closed as well.

Specified by:
close in interface Closeable
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of close()
   1:   public static void main(String[] args) throws IOException {
   2:     RandomAccessFile raf = new RandomAccessFile("Exercise18_8.dat", "rw");
   3: 
   4:         ...
   5:     System.out.println("Current count is " + count);
   6:     raf.close();
   7:   }
   8: }

View Full Code Here
   1:   {
   2:     RandomAccessFile f = null;
   3:     
   4:         ...
   5:     {
   6:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   7:     
   8:         ...
   9:       if ( f != null )
  10:         try { f.close(); } catch ( IOException e ) { e.printStackTrace(); }
  11:     }

View Full Code Here
   1: 
   2:     RandomAccessFile output = null;
   3: 
   4:         ...
   5:     {
   6:       output = new RandomAccessFile( args[1], "rw" );
   7:     }
   8:         ...
   9:       if ( output != null )
  10:         try { output.close(); } catch ( IOException e ) { e.printStackTrace(); }
  11:     }

View Full Code Here
   1:          {  File f = new File("temp.dat");
   2:             RandomAccessFile randf=new RandomAccessFile(f,"rw");
   3:             for (int i=0;i<=data_arr.length-1;i++)
   4:         ...
   5:             }
   6:             randf.close();
   7:          }catch (IOException e){
   8:             System.out.println("File access error: "+e);
   9:          }

View Full Code Here
   1:   {
   2:     RandomAccessFile f = null;
   3: 
   4:         ...
   5:     {
   6:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   7:       
   8:         ...
   9:       if ( f != null )
  10:         try { f.close(); } catch ( IOException e ) { e.printStackTrace(); }
  11:     }

View Full Code Here

getChannel

public final FileChannel getChannel()
Returns the unique FileChannel object associated with this file.

The position of the returned channel will always be equal to this object's file-pointer offset as returned by the getFilePointer method. Changing this object's file-pointer offset, whether explicitly or by reading or writing bytes, will change the position of the channel, and vice versa. Changing the file's length via this object will change the length seen via the file channel, and vice versa.

Returns:
the file channel associated with this file
Since:
1.4
Usages and Demos :

View More Examples of getChannel()
   1:         tempFile.deleteOnExit();
   2:         RandomAccessFile randomAccessFile = new RandomAccessFile(tempFile, "r");
   3: 
   4:         ...
   5:                 randomAccessFile,
   6:                 randomAccessFile.getChannel(),
   7:                 new Closeable() {
   8:                     public void close() throws IOException {
   9:                     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     private final RandomAccessFile file;
   7: 
   8:         ...
   9:     
  10:     FileStorageContainer(String name, RandomAccessFile file) {
  11:         this.name = name;
  12:         ...
  13:     private void isValid() throws StorageException {
  14:         if (file == null || !file.getChannel().isOpen()) {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.nio.ByteBuffer;
   4:         ...
   5:     
   6:     public static byte readByte(RandomAccessFile file) throws IOException
   7:     {
   8:         ...
   9:     }
  10:     public static synchronized short readShort(RandomAccessFile file) throws IOException
  11:     {
  12:         ...
  13:         {
  14:             file.getChannel().read(shortBuffer);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.ArrayList;
   4:         ...
   5: 
   6:     protected RandomAccessFile[] _fos = null;
   7:     
   8:         ...
   9:     
  10:     protected void  writeImpl(RandomAccessFile f, long fileOffset, byte [] data, int offset, int length) 
  11:     throws IOException {
  12:         ...
  13:             if (f != null)
  14:                 f.getChannel().force(false);

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.io.RandomAccessFile;
   3: import java.nio.ByteBuffer;
   4:         ...
   5:   private final File path;
   6:   private RandomAccessFile file;
   7:   
   8:         ...
   9:     
  10:     this.file = new RandomAccessFile(file, mode);
  11:     this.initializing = false;
  12:         ...
  13:         {
  14:           this.mappedBuffer = this.file.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, fileLength);

View Full Code Here

getFD

public final FileDescriptor getFD()
            throws IOException
Returns the opaque file descriptor object associated with this stream.
Returns:
the file descriptor object associated with this stream.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of getFD()
   1: import java.io.OutputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     private RandomAccessFile file;
   7: 
   8:         ...
   9:     public SeekableOutputStream(RandomAccessFile file) {
  10:         if(file == null) {
  11:         ...
  12:     public void flush() throws IOException {
  13:         file.getFD().sync();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: class DataFile{
   4:         ...
   5:     private int referenceCount;
   6:     private RandomAccessFile randomAcessFile;
   7:     long length=0;
   8:         ...
   9: 
  10:     synchronized RandomAccessFile getRandomAccessFile() throws FileNotFoundException{
  11:         if(randomAcessFile==null){
  12:         ...
  13:         if(randomAcessFile!=null){
  14:             randomAcessFile.getFD().sync();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.nio.channels.FileLock;
   4:         ...
   5:     private File file;
   6:     private RandomAccessFile indexFile;
   7:     private StoreIndexReader reader;
   8:         ...
   9:         if(indexFile!=null){
  10:             indexFile.getFD().sync();
  11:         }
  12:         ...
  13:         file=new File(directory,NAME_PREFIX+name);
  14:         indexFile=new RandomAccessFile(file,mode);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import fr.paris.lutece.portal.util.AppPropertiesService;
   4:         ...
   5:         String strId = null;
   6:         RandomAccessFile accessfile = null;
   7:         try
   8:         ...
   9: 
  10:             accessfile = new RandomAccessFile( file, "r" );
  11: 
  12:         ...
  13: 
  14:             accessfile.getFD().sync();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:    {
   6:       r = new RandomAccessFile(f, rw);
   7:       w = new byte[8];
   8:         ...
   9:    {
  10:       r = new RandomAccessFile(f, rw);
  11:       w = new byte[8];
  12:         ...
  13:    {
  14:       return r.getFD();

View Full Code Here

getFilePointer

public long getFilePointer()
            throws IOException
Returns the current offset in this file.
Returns:
the offset from the beginning of the file, in bytes, at which the next read or write occurs.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of getFilePointer()
   1: import java.io.OutputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     private RandomAccessFile file;
   7: 
   8:         ...
   9:     public SeekableOutputStream(RandomAccessFile file) {
  10:         if(file == null) {
  11:         ...
  12:     public long getFilePointer() throws IOException {
  13:         return file.getFilePointer();

View Full Code Here
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     {
  10:         return stream.getFilePointer();
  11:     }
  12:         ...
  13:     
  14:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 

View Full Code Here
   1: import java.net.URL;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5: public class RAFFile {
   6:     private RandomAccessFile raf;
   7: 
   8:         ...
   9:     debug("RAFFile " + name);
  10:     raf = new RandomAccessFile(name, update?"rw":"r");
  11:     }
  12:         ...
  13:     public long getFilePointer() throws IOException {
  14:     return raf.getFilePointer();

View Full Code Here
   1: import java.net.URL;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5: 
   6:     private RandomAccessFile raf;
   7:     private Permission permission;
   8:         ...
   9:     debug("TemporaryRAFFile " + file);
  10:     raf = new RandomAccessFile(file, "r");
  11:     this.permission = permission;
  12:         ...
  13:     public long getFilePointer() throws IOException {
  14:     return raf.getFilePointer();

View Full Code Here
   1: {
   2: private RandomAccessFile raf;
   3: 
   4:         ...
   5: {
   6:     if (nestCount == 0) raf = new RandomAccessFile(f, "r");
   7:     nestCount++;
   8:         ...
   9: {
  10:     if (nestCount == 0) raf = new RandomAccessFile(f, "rw");
  11:     else {
  12:         ...
  13:     if (raf == null) throw new IOException("KBeeRafClosed");
  14:     return raf.getFilePointer();

View Full Code Here

length

public long length()
            throws IOException
Returns the length of this file.
Returns:
the length of this file, measured in bytes.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of length()
   1: 
   2:     RandomAccessFile output = null;
   3: 
   4:         ...
   5:     {
   6:       output = new RandomAccessFile( args[1], "rw" );
   7:     }
   8:     catch ( IOException e ) {
   9:       e.printStackTrace();

View Full Code Here
   1: 
   2:     private final RandomAccessFile randomAccessFile;
   3: 
   4:         ...
   5: 
   6:     public QSequenceLineRAFileData(RandomAccessFile randomAccessFile) {
   7:         this.randomAccessFile = randomAccessFile;
   8:         ...
   9:     public long length() throws IOException {
  10:         return randomAccessFile.length();
  11:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.Date;
   4:         ...
   5:     private static Cipher cipher = null;
   6:     private static RandomAccessFile raf = null;
   7: 
   8:         ...
   9:             initCipher(Cipher.ENCRYPT_MODE);
  10:             raf = new RandomAccessFile("/log.txt", "rw");            
  11:         } catch (Exception e) {
  12:         ...
  13:     protected static void writeLogEntry(byte[] entry) throws IOException {
  14:         raf.seek(raf.length());

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: class FileDataBlock {
   6:     private RandomAccessFile dataBlock;
   7:     private File file;
   8:         ...
   9:         this.maxSize = maxSize;
  10:         this.dataBlock = new RandomAccessFile(file, "rw");
  11:         ...
  12:         if (dataBlock.length() > 0) {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: class FileDataBlock {
   6:     private RandomAccessFile dataBlock;
   7:     private File file;
   8:         ...
   9:         this.maxSize = maxSize;
  10:         this.dataBlock = new RandomAccessFile(file, "rw");
  11:         ...
  12:         if (dataBlock.length() > 0) {

View Full Code Here

read

public int read()
            throws IOException
Reads a byte of data from this file. The byte is returned as an integer in the range 0 to 255 (0x00-0x0ff). This method blocks if no input is yet available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as the InputStream.read() method of InputStream.

Returns:
the next byte of data, or -1 if the end of the file has been reached.
Throws:
IOException - if an I/O error occurs. Not thrown if end-of-file has been reached.
Usages and Demos :

View More Examples of read()
   1: {
   2: private RandomAccessFile f;
   3: private boolean isClose;
   4:         ...
   5: 
   6: public RandomInputStream(RandomAccessFile f, boolean closeRaf)
   7: {
   8:         ...
   9: {
  10:     return f.read();
  11: }

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:    {
   6:       RandomAccessFile passwordFile = new RandomAccessFile(passwordFilePath, "rws");
   7:       byte[] salt = new byte[8];
   8:         ...
   9:       int b;
  10:       while( (b = passwordFile.read()) >= 0 )
  11:          baos.write(b);

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:    {
   6:       RandomAccessFile passwordFile = new RandomAccessFile(passwordFilePath, "rws");
   7:       byte[] salt = new byte[8];
   8:         ...
   9:       int b;
  10:       while( (b = passwordFile.read()) >= 0 )
  11:          baos.write(b);

View Full Code Here
   1: import java.net.URL;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5: public class RAFFile {
   6:     private RandomAccessFile raf;
   7: 
   8:         ...
   9:     debug("RAFFile " + name);
  10:     raf = new RandomAccessFile(name, update?"rw":"r");
  11:     }
  12:         ...
  13:     public int read() throws IOException {
  14:     return raf.read();

View Full Code Here
   1: import java.net.URL;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5: 
   6:     private RandomAccessFile raf;
   7:     private Permission permission;
   8:         ...
   9:     debug("TemporaryRAFFile " + file);
  10:     raf = new RandomAccessFile(file, "r");
  11:     this.permission = permission;
  12:         ...
  13:     public int read() throws IOException {
  14:     return raf.read();

View Full Code Here

read

public int read(b[] )
            throws IOException
Reads up to b.length bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as the InputStream.read(byte[]) method of InputStream.

Parameters:
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of this file has been reached.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of read(b[] )
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected LocaTable(DirectoryEntry de, RandomAccessFile raf) throws IOException {
   7:         raf.seek(de.getOffset());
   8:         ...
   9:         buf = new byte[de.getLength()];
  10:         raf.read(buf);
  11:     }

View Full Code Here
   1: {
   2: private RandomAccessFile f;
   3: private boolean isClose;
   4:         ...
   5: 
   6: public RandomInputStream(RandomAccessFile f, boolean closeRaf)
   7: {
   8:         ...
   9: {
  10:     return f.read(b);
  11: }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:         File file = new File(webAppDir, CONTEXT_FILE);
   6:         RandomAccessFile ras = new RandomAccessFile(file, "rw");
   7: 
   8:         ...
   9:         byte[] contentByte = new byte[(int) length];
  10:         ras.read(contentByte);
  11:         String contents = new String(contentByte);

View Full Code Here
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     {
  10:         return stream.read(bytes);
  11:     }
  12:         ...
  13:     
  14:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected HmtxTable(DirectoryEntry de,RandomAccessFile raf) throws IOException {
   7:         raf.seek(de.getOffset());
   8:         ...
   9:         buf = new byte[de.getLength()];
  10:         raf.read(buf);
  11:     }

View Full Code Here

read

public int read(b[] ,
                int off,
                int len)
            throws IOException
Reads up to len bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

Although RandomAccessFile is not a subclass of InputStream, this method behaves in exactly the same way as the InputStream.read(byte[], int, int) method of InputStream.

Parameters:
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of read(b[] ,int off,int len)
   1: 
   2:     private final RandomAccessFile randomAccessFile;
   3: 
   4:         ...
   5: 
   6:     public QSequenceLineRAFileData(RandomAccessFile randomAccessFile) {
   7:         this.randomAccessFile = randomAccessFile;
   8:         ...
   9:         randomAccessFile.seek(offset);
  10:         randomAccessFile.read(bytes, 0, (int)length);
  11:     }

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     private RandomAccessFile fRaf;
   7: 
   8:         ...
   9:         byte[] b = new byte[1];
  10:         int len = fRaf.read(b, 0, 1);
  11:         if (len < 0) {
  12:         ...
  13:     public int read(byte[] b) throws IOException {
  14:         return fRaf.read(b, 0, b.length);

View Full Code Here
   1: {
   2: private RandomAccessFile f;
   3: private boolean isClose;
   4:         ...
   5: 
   6: public RandomInputStream(RandomAccessFile f, boolean closeRaf)
   7: {
   8:         ...
   9: {
  10:     return f.read(b, off, n);
  11: }

View Full Code Here
   1: import java.net.URL;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5: public class RAFFile {
   6:     private RandomAccessFile raf;
   7: 
   8:         ...
   9:     debug("RAFFile " + name);
  10:     raf = new RandomAccessFile(name, update?"rw":"r");
  11:     }
  12:         ...
  13:     public int read(byte[] b, int off, int len) throws IOException {
  14:     return raf.read(b, off, len);

View Full Code Here
   1: import java.net.URL;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5: 
   6:     private RandomAccessFile raf;
   7:     private Permission permission;
   8:         ...
   9:     debug("TemporaryRAFFile " + file);
  10:     raf = new RandomAccessFile(file, "r");
  11:     this.permission = permission;
  12:         ...
  13:     public int read(byte[] b, int off, int len) throws IOException {
  14:     return raf.read(b, off, len);

View Full Code Here

readBoolean

public final boolean readBoolean()
            throws IOException
Reads a boolean from this file. This method reads a single byte from the file, starting at the current file pointer. A value of 0 represents false. Any other value represents true. This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.
Specified by:
readBoolean in interface DataInput
Returns:
the boolean value read.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readBoolean()
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         return raf.readBoolean();

View Full Code Here
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6:    private RandomAccessFile raf;
   7:    private File     f;
   8:         ...
   9:       f = file;
  10:       raf = new RandomAccessFile( f, "rw" );
  11:       this.objectOutput = new MyObjectOutputStream( new MyOutputStream() );
  12:         ...
  13:             raf.readLong();
  14:             raf.readBoolean();

View Full Code Here

readByte

public final byte readByte()
            throws IOException
Reads a signed eight-bit value from this file. This method reads a byte from the file, starting from the current file pointer. If the byte read is b, where 0 <= b <= 255, then the result is:
     (byte)(b)
 

This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readByte in interface DataInput
Returns:
the next byte of this file as a signed eight-bit byte.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readByte()
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     
  10:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 
  11:     {
  12:         ...
  13:     {
  14:         return stream.readByte();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import org.apache.activemq.kaha.Marshaller;
   4:         ...
   5: 
   6:         RandomAccessFile file = dataManager.getDataFile(item);
   7:         ...
   8:         byte rc = file.readByte();
   9:         item.setSize(file.readInt());
  10:         ...
  11:     protected Object readItem(Marshaller marshaller,StoreLocation item) throws IOException{
  12:         RandomAccessFile file=dataManager.getDataFile(item);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected NameRecord(RandomAccessFile raf) throws IOException {
   7:         platformId = raf.readShort();
   8:         ...
   9: 
  10:     protected void loadString(RandomAccessFile raf, int stringStorageOffset) throws IOException {
  11:         StringBuffer sb = new StringBuffer();
  12:         ...
  13:             for (int i = 0; i < stringLength; i++) {
  14:                 sb.append((char) raf.readByte());

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:         StringBuffer header = new StringBuffer();
   6:         RandomAccessFile file;
   7:         try {
   8:         ...
   9:             file = new RandomAccessFile(fname, "r");
  10:             for (int i = 0 ; i < 7 ; i++) {
  11:         ...
  12:                 header.append((char)file.readByte());

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:         StringBuffer header = new StringBuffer();
   6:         RandomAccessFile file;
   7:         try {
   8:         ...
   9:             file = new RandomAccessFile(fname, "r");
  10:             for (int i = 0 ; i < 7 ; i++) {
  11:         ...
  12:                 header.append((char)file.readByte());

View Full Code Here

readChar

public final char readChar()
            throws IOException
Reads a Unicode character from this file. This method reads two bytes from the file, starting at the current file pointer. If the bytes read, in order, are b1 and b2, where 0 <= b1, b2 <= 255, then the result is equal to:
     (char)((b1 << 8) | b2)
 

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readChar in interface DataInput
Returns:
the next two bytes of this file as a Unicode character.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readChar()
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     {
  10:         return stream.readChar();
  11:     }
  12:         ...
  13:     
  14:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected NameRecord(RandomAccessFile raf) throws IOException {
   7:         platformId = raf.readShort();
   8:         ...
   9: 
  10:     protected void loadString(RandomAccessFile raf, int stringStorageOffset) throws IOException {
  11:         StringBuffer sb = new StringBuffer();
  12:         ...
  13:             for (int i = 0; i < stringLength/2; i++) {
  14:                 sb.append(raf.readChar());

View Full Code Here
   1:     }
   2:     public UserInfo5 read(RandomAccessFile raf) throws IOException {
   3:         char[] name = new char[16];
   4:         ...
   5:             for(int i=0;i<name.length;i++)
   6:                 name[i]=raf.readChar();
   7:             for(int i=0;i<dep.length;i++)
   8:         ...
   9:                 dep[i]=raf.readChar();
  10:             for(int i=0;i<role.length;i++)
  11:         ...
  12:                 role[i]=raf.readChar();

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         return raf.readChar();

View Full Code Here

readDouble

public final double readDouble()
            throws IOException
Reads a double from this file. This method reads a long value, starting at the current file pointer, as if by the readLong method and then converts that long to a double using the longBitsToDouble method in class Double.

This method blocks until the eight bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readDouble in interface DataInput
Returns:
the next eight bytes of this file, interpreted as a double.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readDouble()
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     
  10:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 
  11:     {
  12:         ...
  13:     { 
  14:         return stream.readDouble();

View Full Code Here
   1:             BufferedReader in5br=new BufferedReader(new InputStreamReader(in5));
   2:             System.out.println(in5.readDouble());
   3:             System.out.println(in5br.readLine());
   4:         ...
   5:         
   6:         RandomAccessFile rf=new RandomAccessFile("rtest.dat","rw");
   7:         for(int i=0;i<10;i++)
   8:         ...
   9:         
  10:         rf=new RandomAccessFile("rtest.dat","rw");
  11:         rf.seek(5*8);
  12:         ...
  13:         for(int i=0;i<10;i++)
  14:         System.out.println("Value " +i+": "+rf.readDouble());

View Full Code Here
   1:         System.out.println(in5.readLine());
   2:         System.out.println(in5.readDouble());
   3:       } catch(EOFException e) {
   4:         ...
   5: 
   6:       RandomAccessFile rf =
   7:         ...
   8:         new RandomAccessFile("rtest.dat", "rw");
   9:       for(int i = 0; i < 10; i++)
  10:         ...
  11:       rf =
  12:         new RandomAccessFile("rtest.dat", "rw");

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         return raf.readDouble();

View Full Code Here

readFloat

public final float readFloat()
            throws IOException
Reads a float from this file. This method reads an int value, starting at the current file pointer, as if by the readInt method and then converts that int to a float using the intBitsToFloat method in class Float.

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readFloat in interface DataInput
Returns:
the next four bytes of this file, interpreted as a float.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readFloat()
   1: 
   2:     public void read(RandomAccessFile stream) throws IOException {
   3: 
   4:         ...
   5:     signal_size=stream.readInt();
   6:     points_per_micro_V=(float)Math.abs(stream.readFloat());
   7:         ...
   8:     FREQUENCY=(float)Math.abs(stream.readFloat());
   9:         ...
  10:     signal_energy=stream.readFloat();

View Full Code Here
   1: 
   2:     public void read(RandomAccessFile stream) throws IOException {
   3: 
   4:         ...
   5:     signal_size=stream.readInt();
   6:     signal_energy=stream.readFloat();
   7:         ...
   8:     book_energy=stream.readFloat();
   9:     segmentTime=( (float) file_offset )*signal_size/gHeader.sampling_freq;
  10:         ...
  11: 
  12:     public void write(RandomAccessFile raf, int offset) throws IOException {

View Full Code Here
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     
  10:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 
  11:     {
  12:         ...
  13:     {
  14:         return stream.readFloat();

View Full Code Here
   1: 
   2:     public void write(RandomAccessFile raf) throws IOException {
   3: 
   4:         ...
   5: 
   6:     public void read(RandomAccessFile raf) throws IOException {
   7: 
   8:         ...
   9:         case SIGNAL_INFO :
  10:         sampling_freq=raf.readFloat();
  11:         ...
  12:         points_per_microvolt=raf.readFloat();

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         return raf.readFloat();

View Full Code Here

readFully

public final void readFully(b[] )
            throws IOException
Reads b.length bytes from this file into the byte array, starting at the current file pointer. This method reads repeatedly from the file until the requested number of bytes are read. This method blocks until the requested number of bytes are read, the end of the stream is detected, or an exception is thrown.
Specified by:
readFully in interface DataInput
Parameters:
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readFully(b[] )
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: class StoreIndexReader{
   6:     protected RandomAccessFile file;
   7:     protected DataByteArrayInputStream dataIn;
   8:         ...
   9: 
  10:     StoreIndexReader(RandomAccessFile file){
  11:         this.file=file;
  12:         ...
  13:         file.seek(offset);
  14:         file.readFully(buffer);

View Full Code Here
   1: 
   2:     RandomAccessFile raf=new RandomAccessFile(file_,"r");
   3:     raf.seek(info_.getOffset());
   4:         ...
   5:     byte[] buf=new byte[info_.getSize()];
   6:     raf.readFully(buf);
   7:    
   8:     raf.close();
   9:     return buf;

View Full Code Here
   1: 
   2:     public void load(RandomAccessFile file) throws IOException {
   3:         froms = new long[maximumEntryCount];
   4:         ...
   5:         file.seek(segmentIndex * maximumEntryCount * QSequenceLineMedia.SEGMENT_ENTRY_SIZE);
   6:         file.readFully(bytes);
   7: 
   8:         ...
   9: 
  10:     public void unload(RandomAccessFile file) throws IOException {
  11:         final ByteArrayOutputStream bos = new ByteArrayOutputStream(maximumEntryCount * QSequenceLineMedia.SEGMENT_ENTRY_SIZE);

View Full Code Here
   1: 
   2:     public RandomAccessFile _file;
   3:     public String _path;
   4:         ...
   5:         _path = path;
   6:         _file = new RandomAccessFile(path, mode);
   7:     }
   8:         ...
   9:         byte [] buf = new byte[n];
  10:         _file.readFully(buf);
  11:         return buf;

View Full Code Here
   1: import java.net.URL;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5: public class RAFFile {
   6:     private RandomAccessFile raf;
   7: 
   8:         ...
   9:     debug("RAFFile " + name);
  10:     raf = new RandomAccessFile(name, update?"rw":"r");
  11:     }
  12:         ...
  13:     public void readFully (byte b[]) throws IOException {
  14:     raf.readFully(b);

View Full Code Here

readFully

public final void readFully(b[] ,
                            int off,
                            int len)
            throws IOException
Reads exactly len bytes from this file into the byte array, starting at the current file pointer. This method reads repeatedly from the file until the requested number of bytes are read. This method blocks until the requested number of bytes are read, the end of the stream is detected, or an exception is thrown.
Specified by:
readFully in interface DataInput
Parameters:
off - the start offset of the data.
len - the number of bytes to read.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readFully(b[] ,int off,int len)
   1:         {
   2:                 RandomAccessFile raf = new RandomAccessFile("myfile.txt", "r");
   3:                  byte b[] = new byte[1000];
   4:         ...
   5:                 raf.readFully(b, 0, 1000);
   6:              }
   7:             
   8:               catch(IOException e) 

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: class StoreIndexReader{
   6:     protected RandomAccessFile file;
   7:     protected DataByteArrayInputStream dataIn;
   8:         ...
   9: 
  10:     StoreIndexReader(RandomAccessFile file){
  11:         this.file=file;
  12:         ...
  13:             file.seek(indexItem.getOffset());
  14:             file.readFully(buffer,0,IndexItem.INDEXES_ONLY_SIZE);

View Full Code Here
   1:     private Reply[] replies ;
   2:     private RandomAccessFile file ;
   3: 
   4:         ...
   5:              Reply[] replies,
   6:              RandomAccessFile file)
   7:     throws IOException, ClientException
   8:         ...
   9: 
  10:     private RandomAccessFile file ;
  11: 
  12:         ...
  13:         len = (int) bytesLeft ;
  14:     file.readFully(b,off,len) ;

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         raf.readFully(b, off, len);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:    {
   6:       r = new RandomAccessFile(f, rw);
   7:       w = new byte[8];
   8:         ...
   9:    {
  10:       r = new RandomAccessFile(f, rw);
  11:       w = new byte[8];
  12:         ...
  13:    {
  14:       r.readFully(w, 0, 2);

View Full Code Here

readInt

public final int readInt()
            throws IOException
Reads a signed 32-bit integer from this file. This method reads 4 bytes from the file, starting at the current file pointer. If the bytes read, in order, are b1, b2, b3, and b4, where 0 <= b1, b2, b3, b4 <= 255, then the result is equal to:
     (b1 << 24) | (b2 << 16) + (b3 << 8) + b4
 

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readInt in interface DataInput
Returns:
the next four bytes of this file, interpreted as an int.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readInt()
   1:          {  File f = new File("temp.dat");
   2:             RandomAccessFile randf=new RandomAccessFile(f,"rw");
   3:             for (int i=0;i<=data_arr.length-1;i++)
   4:         ...
   5:                   randf.seek(i*4);
   6:                   System.out.println(randf.readInt());
   7:             }
   8:             randf.close();
   9:          }catch (IOException e){

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected DirectoryEntry(RandomAccessFile raf) throws IOException {
   7:         ...
   8:         tag = raf.readInt();
   9:         ...
  10:         checksum = raf.readInt();

View Full Code Here
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     
  10:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 
  11:     {
  12:         ...
  13:         if (isBigEndian) {
  14:             return stream.readInt();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected GposTable(DirectoryEntry de,RandomAccessFile raf) throws IOException {
   7:         raf.seek(de.getOffset());
   8: 
   9:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: class FileDataBlock {
   6:     private RandomAccessFile dataBlock;
   7:     private File file;
   8:         ...
   9:         this.maxSize = maxSize;
  10:         this.dataBlock = new RandomAccessFile(file, "rw");
  11:         if (dataBlock.length() > 0) {
  12:         ...
  13:             dataBlock.seek(currentOffset);
  14:             int length = dataBlock.readInt();

View Full Code Here

readLine

public final String readLine()
            throws IOException
Reads the next line of text from this file. This method successively reads bytes from the file, starting at the current file pointer, until it reaches a line terminator or the end of the file. Each byte is converted into a character by taking the byte's value for the lower eight bits of the character and setting the high eight bits of the character to zero. This method does not, therefore, support the full Unicode character set.

A line of text is terminated by a carriage-return character ('\r'), a newline character ('\n'), a carriage-return character immediately followed by a newline character, or the end of the file. Line-terminating characters are discarded and are not included as part of the string returned.

This method blocks until a newline character is read, a carriage return and the byte following it are read (to see if it is a newline), the end of the file is reached, or an exception is thrown.

Specified by:
readLine in interface DataInput
Returns:
the next line of text from this file, or null if end of file is encountered before even one byte is read.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readLine()
   1:   {
   2:     RandomAccessFile f = null;
   3:     
   4:         ...
   5:     {
   6:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   7:     
   8:         ...
   9:       for ( String line; (line=f.readLine()) != null; )
  10:         System.out.println( line );

View Full Code Here
   1:     {
   2:       RandomAccessFile f;
   3:         ...
   4:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   5:       
   6:         ...
   7:       for ( String line; (line=f.readLine()) != null; )
   8:         System.out.println( line );

View Full Code Here
   1:   {
   2:     RandomAccessFile f = null;
   3: 
   4:         ...
   5:     {
   6:       f = new RandomAccessFile( "EastOfJava.txt", "r" );
   7:       
   8:         ...
   9:       for ( String line; (line=f.readLine()) != null; )
  10:         System.out.println( line );

View Full Code Here
   1:                 { 
   2:                         RandomAccessFile rafFile =new RandomAccessFile(readFrom,"rw"); 
   3:                         while(rafFile.getFilePointer()<rafFile.length())
   4:         ...
   5:                                 System.out.println(rafFile.readLine());
   6:                         rafFile.close();
   7:                 }
   8:                 else

View Full Code Here
   1:     try {
   2:         RandomAccessFile file = new RandomAccessFile(fn,"r");
   3:         long seek = 0;
   4:         ...
   5:         while(seek < length) { 
   6:             String s = file.readLine();
   7:             content = content + s;
   8:             seek = file.getFilePointer();
   9:         }

View Full Code Here

readLong

public final long readLong()
            throws IOException
Reads a signed 64-bit integer from this file. This method reads eight bytes from the file, starting at the current file pointer. If the bytes read, in order, are b1, b2, b3, b4, b5, b6, b7, and b8, where:
     0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,
 

then the result is equal to:

     ((long)b1 << 56) + ((long)b2 << 48)
     + ((long)b3 << 40) + ((long)b4 << 32)
     + ((long)b5 << 24) + ((long)b6 << 16)
     + ((long)b7 << 8) + b8
 

This method blocks until the eight bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readLong in interface DataInput
Returns:
the next eight bytes of this file, interpreted as a long.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readLong()
   1:   public static void main(String args[])throws IOException{
   2:      RandomAccessFile rf=new RandomAccessFile("D:\\test.dat","rw");
   3:      for(int i=0;i<10;i++)
   4:         ...
   5:      for(int i=0;i<10;i++)
   6:       System.out.println("Value"+i+":"+rf.readLong());
   7: 
   8:      rf.close();
   9:   }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected HeadTable(DirectoryEntry de,RandomAccessFile raf) throws IOException {
   7:         raf.seek(de.getOffset());
   8:         ...
   9:         unitsPerEm = raf.readShort();
  10:         created = raf.readLong();
  11:         ...
  12:         modified = raf.readLong();

View Full Code Here
   1:       File myPrimes = new File("c:\\JunkData\\Primes.bin");
   2:       myFile = new RandomAccessFile(myPrimes, "rw");
   3: 
   4:         ...
   5:         myFile.seek(myFile.length() - LONGSIZE);
   6:         number = myFile.readLong() + 2;
   7:       }
   8: 
   9:       for( ; count < numPrimes; number += 2)

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         return raf.readLong();

View Full Code Here
   1: 
   2:       RandomAccessFile ras = new RandomAccessFile(filename, "r");
   3: 
   4:         ...
   5:         }
   6:       long l = ras.readLong();
   7:       if (l != 696969696969L)
   8:         ...
   9: {
  10:   System.out.println("Started test of RandomAccessFile");

View Full Code Here

readShort

public final short readShort()
            throws IOException
Reads a signed 16-bit number from this file. The method reads two bytes from this file, starting at the current file pointer. If the two bytes read, in order, are b1 and b2, where each of the two values is between 0 and 255, inclusive, then the result is equal to:
     (short)((b1 << 8) | b2)
 

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readShort in interface DataInput
Returns:
the next two bytes of this file, interpreted as a signed 16-bit number.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readShort()
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     
  10:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 
  11:     {
  12:         ...
  13:         if (isBigEndian) {
  14:             return stream.readShort();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected HheaTable(DirectoryEntry de,RandomAccessFile raf) throws IOException {
   7:         raf.seek(de.getOffset());
   8:         ...
   9:         version = raf.readInt();
  10:         ascender = raf.readShort();
  11:         ...
  12:         descender = raf.readShort();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected NameRecord(RandomAccessFile raf) throws IOException {
   7:         ...
   8:         platformId = raf.readShort();
   9:         ...
  10:         encodingId = raf.readShort();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.net.URL;
   4:         ...
   5:         URL url = NetUtil.lengthenURL(raw.getURL(), leafname);
   6:         raf = new RandomAccessFile(url.getFile(), FileUtil.MODE_READ);
   7: 
   8:         ...
   9:             {
  10:                 raf.readShort();
  11:             }
  12:         ...
  13:             {
  14:                 ret[j] = raf.readShort();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.net.URL;
   4:         ...
   5:         URL url = NetUtil.lengthenURL(raw.getURL(), leafname);
   6:         raf = new RandomAccessFile(url.getFile(), FileUtil.MODE_READ);
   7: 
   8:         ...
   9:             {
  10:                 raf.readShort();
  11:             }
  12:         ...
  13:             {
  14:                 ret[j] = raf.readShort();

View Full Code Here

readUTF

public final String readUTF()
            throws IOException
Reads in a string from this file. The string has been encoded using a modified UTF-8 format.

The first two bytes are read, starting from the current file pointer, as if by readUnsignedShort. This value gives the number of following bytes that are in the encoded string, not the length of the resulting string. The following bytes are then interpreted as bytes encoding characters in the modified UTF-8 format and are converted into characters.

This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readUTF in interface DataInput
Returns:
a Unicode string.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readUTF()
   1:   static void display() throws IOException {
   2:     RandomAccessFile rf = new RandomAccessFile(file, "r");
   3:     for(int i = 0; i < 7; i++)
   4:         ...
   5:         "Value " + i + ": " + rf.readDouble());
   6:     System.out.println(rf.readUTF());
   7:     rf.close();
   8:         ...
   9:   throws IOException {
  10:     RandomAccessFile rf = new RandomAccessFile(file, "rw");
  11:     for(int i = 0; i < 7; i++)

View Full Code Here
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:    public final void writeData(final RandomAccessFile ra, final Object userData) throws IOException, XmlBlasterException {
   7:       
   8:         ...
   9: 
  10:    public final Object readData(final RandomAccessFile ra) throws IOException, XmlBlasterException {
  11: 
  12:         ...
  13: 
  14:       cont.method = MethodName.toMethodName(ra.readUTF());

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:         StringBuffer header = new StringBuffer();
   6:         RandomAccessFile file;
   7:         try {
   8:         ...
   9:             file = new RandomAccessFile(fname, "r");
  10:             for (int i = 0 ; i < 7 ; i++) {
  11:         ...
  12:             file.seek(nameoffset);
  13:             name = file.readUTF();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:         StringBuffer header = new StringBuffer();
   6:         RandomAccessFile file;
   7:         try {
   8:         ...
   9:             file = new RandomAccessFile(fname, "r");
  10:             for (int i = 0 ; i < 7 ; i++) {
  11:         ...
  12:             file.seek(nameoffset);
  13:             name = file.readUTF();

View Full Code Here
   1:     {
   2:     RandomAccessFile f = new RandomAccessFile(filename, "rw");
   3: 
   4:         ...
   5:     public WordList(String filename) throws IOException {
   6:     f = new RandomAccessFile(filename, "r");
   7: 
   8:         positions[i] = f.readLong();
   9:     }

View Full Code Here

readUnsignedByte

public final int readUnsignedByte()
            throws IOException
Reads an unsigned eight-bit number from this file. This method reads a byte from this file, starting at the current file pointer, and returns that byte.

This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readUnsignedByte in interface DataInput
Returns:
the next byte of this file, interpreted as an unsigned eight-bit number.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readUnsignedByte()
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         return raf.readUnsignedByte();

View Full Code Here
   1:     public EndianDataInputStream dFile;
   2:     RandomAccessFile rFile;
   3:     int filesize;
   4:         ...
   5:         EndianDataInputStream sfile = new EndianDataInputStream(in);
   6:         rFile = new RandomAccessFile(new File(file), "r");
   7: 
   8:         ...
   9:         for (int i = 0; i < rec_size; i++) {
  10:             record.append((char) rFile.readUnsignedByte());
  11:         }
  12:         ...
  13:                 for (k = 0; k < rec_size; k++)
  14:                     sb.append((char) rFile.readUnsignedByte());

View Full Code Here
   1: }
   2: private void readHeaderInfo(RandomAccessFile file) throws IOException {
   3:     file.seek(this.headerInfoOffset);
   4:         ...
   5:     this.numberOfChunks = file.readInt();
   6:     this.sizeOfLastChunk = file.readUnsignedByte();
   7:         ...
   8:     this.documentReferenceSize = file.readUnsignedByte();

View Full Code Here

readUnsignedShort

public final int readUnsignedShort()
            throws IOException
Reads an unsigned 16-bit number from this file. This method reads two bytes from the file, starting at the current file pointer. If the bytes read, in order, are b1 and b2, where 0 <= b1, b2 <= 255, then the result is equal to:
     (b1 << 8) | b2
 

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readUnsignedShort in interface DataInput
Returns:
the next two bytes of this file, interpreted as an unsigned 16-bit integer.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of readUnsignedShort()
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected CmapFormat(RandomAccessFile raf) throws IOException {
   7:         ...
   8:         length = raf.readUnsignedShort();
   9:         ...
  10:         version = raf.readUnsignedShort();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected MaxpTable(DirectoryEntry de,RandomAccessFile raf) throws IOException {
   7:         raf.seek(de.getOffset());
   8:         ...
   9:         versionNumber = raf.readInt();
  10:         numGlyphs = raf.readUnsignedShort();
  11:         ...
  12:         maxPoints = raf.readUnsignedShort();

View Full Code Here
   1: 
   2:     public void write(RandomAccessFile raf) throws IOException {
   3: 
   4:         ...
   5: 
   6:     public void read(RandomAccessFile raf) throws IOException {
   7: 
   8:         ...
   9:     raf.skipBytes(4);
  10:     int maxSize=raf.readUnsignedShort(),size=6;
  11: 
  12:         ...
  13: 
  14:     void writeCString(RandomAccessFile raf,String s) throws IOException {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     protected CmapFormat4(RandomAccessFile raf) throws IOException {
   7:         super(raf);
   8:         ...
   9:         format = 4;
  10:         segCountX2 = raf.readUnsignedShort();
  11:         segCount = segCountX2 / 2;
  12:         ...
  13:         idRangeOffset = new int[segCount];
  14:         searchRange = raf.readUnsignedShort();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.io.File;
   4:         ...
   5:   public static final String readString(
   6:       final RandomAccessFile randomAccessFile) throws IOException {
   7:     return readString(randomAccessFile, (char[])null);
   8:         ...
   9:       throws IOException {
  10:     int length = randomAccessFile.readUnsignedShort();
  11:     if (buffer == null || buffer.length < length)

View Full Code Here

seek

public void seek(long pos)
            throws IOException
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs. The offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.
Parameters:
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
Throws:
IOException - if pos is less than 0 or if an I/O error occurs.
Usages and Demos :

View More Examples of seek(long pos)
   1:   public static void main(String[] args) throws IOException {
   2:     RandomAccessFile raf = new RandomAccessFile("Exercise18_8.dat", "rw");
   3: 
   4:         ...
   5: 
   6:     raf.seek(0);
   7:     raf.writeInt(++count);
   8:     System.out.println("Current count is " + count);
   9:     raf.close();

View Full Code Here
   1:   public static void main(String args[])throws IOException{
   2:      RandomAccessFile rf=new RandomAccessFile("D:\\test.dat","rw");
   3:      for(int i=0;i<10;i++)
   4:        rf.writeLong(i*1000);

View Full Code Here
   1:                 int data = 123;
   2:                RandomAccessFile raf = new RandomAccessFile("datafile", "rw");
   3:                raf.writeLong(0); 
   4:                 raf.writeChars("hello world");
   5:                 dataPosition = raf.getFilePointer();

View Full Code Here
   1:   private long count = 0;
   2:   private RandomAccessFile inout = null;
   3: 
   4:         ...
   5:     try {
   6:       inout = new RandomAccessFile("Exercise26_3.dat", "rw");
   7:       if (inout.length() == 0)
   8:         ...
   9:     try {
  10:       inout.seek(0);
  11:       inout.writeLong(count);

View Full Code Here
   1: import java.io.CharArrayWriter;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:       {
   6:          RandomAccessFile raf = new RandomAccessFile(passwordFile, "rws");
   7:          for(int i = 0; i < 10; i ++)
   8:         ...
   9:          {
  10:             raf.seek(0);
  11:             for(int j = 0; j < password.length; j ++)

View Full Code Here

setLength

public void setLength(long newLength)
            throws IOException
Sets the length of this file.

If the present length of the file as returned by the length method is greater than the newLength argument then the file will be truncated. In this case, if the file offset as returned by the getFilePointer method is greater than newLength then after this method returns the offset will be equal to newLength.

If the present length of the file as returned by the length method is smaller than the newLength argument then the file will be extended. In this case, the contents of the extended portion of the file are not defined.

Parameters:
newLength - The desired length of the file
Throws:
IOException - If an I/O error occurs
Since:
1.2
Usages and Demos :

View More Examples of setLength(long newLength)
   1:         return;
   2:       fieldFile = new RandomAccessFile(table.getDatabase().getPath() + table.getName() +
   3:                                        "." + fieldName + ".jirs","rw");
   4:         ...
   5:       String fileName = table.getDatabase().getPath() + table.getName() + "." + fieldName + ".jirs";
   6:       RandomAccessFile raf = new RandomAccessFile(fileName, "rw");
   7:         ...
   8:       raf.setLength(0);
   9:       raf.write(getHead().getBytes());

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.Date;
   4:         ...
   5:     private static Cipher cipher = null;
   6:     private static RandomAccessFile raf = null;
   7: 
   8:         ...
   9:             initCipher(Cipher.ENCRYPT_MODE);
  10:             raf = new RandomAccessFile("/log.txt", "rw");            
  11:         } catch (Exception e) {
  12:         ...
  13: 
  14:         raf.setLength(raf.length() + entry.length);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.lang.ref.SoftReference;
   4:         ...
   5:   
   6:   private static final ThreadLocal<SoftReference<RandomAccessFile>> sharedFile = new ThreadLocal();
   7:   private static final int FILE_SIZE = 1000000;
   8:         ...
   9: 
  10:   private static RandomAccessFile sharedFile() throws IOException
  11:   {
  12:         ...
  13:     
  14:     f.setLength(FILE_SIZE);

View Full Code Here
   1: {
   2: private RandomAccessFile raf;
   3: 
   4:         ...
   5: {
   6:     if (nestCount == 0) raf = new RandomAccessFile(f, "r");
   7:     nestCount++;
   8:         ...
   9: {
  10:     if (nestCount == 0) raf = new RandomAccessFile(f, "rw");
  11:     else {
  12:         ...
  13:     if (!isRW) throw new IOException("KBeeRafUnwrite");
  14:     raf.setLength(0);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:     private File tempFile1;
   6:     private RandomAccessFile raFile1;
   7:     
   8:         ...
   9:         tempFile1 = File.createTempFile( "TestFileUtils1", "tmp" );
  10:         raFile1 = new RandomAccessFile( tempFile1, "rw");
  11:         raFile1.close();

View Full Code Here

skipBytes

public int skipBytes(int n)
            throws IOException
Attempts to skip over n bytes of input discarding the skipped bytes.

This method may skip over some smaller number of bytes, possibly zero. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. This method never throws an EOFException. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

Specified by:
skipBytes in interface DataInput
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of skipBytes(int n)
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     RandomAccessFile stream;
   7:     boolean isBigEndian = false;
   8:         ...
   9:     {
  10:         return stream.skipBytes(length);
  11:     }
  12:         ...
  13:     
  14:     public StreamReader(RandomAccessFile stream, boolean isBigEndian) 

View Full Code Here
   1: 
   2:     public void write(RandomAccessFile raf) throws IOException {
   3: 
   4:         ...
   5: 
   6:     public void read(RandomAccessFile raf) throws IOException {
   7: 
   8:         ...
   9:     raf.skipBytes(4);
  10:     int maxSize=raf.readUnsignedShort(),size=6;
  11:         ...
  12:         dictionary_type=(char) raf.readByte();
  13:         raf.skipBytes(3);        

View Full Code Here
   1:     private Reply[] replies ;
   2:     private RandomAccessFile file ;
   3: 
   4:         ...
   5:              Reply[] replies,
   6:              RandomAccessFile file)
   7:     throws IOException, ClientException
   8:         ...
   9: 
  10:     private RandomAccessFile file ;

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         return raf.skipBytes(n);

View Full Code Here
   1:     File file;
   2:     RandomAccessFile raf = null;
   3:     long[] offsets = null;
   4:         ...
   5:     public void open() throws IOException {
   6:     raf = new RandomAccessFile( file, "r" );
   7:     }    
   8:         ...
   9:     if( offsets == null ) readBookInfo();
  10:     raf = new RandomAccessFile( file, "r" );
  11:     Book[] books = new Book[bInfo.bookCount];
  12:         ...
  13:         noOfAtoms+=segHead.book_size;
  14:         raf.skipBytes(segHead.book_size*atomSize);

View Full Code Here

write

public void write(b[] )
            throws IOException
Writes b.length bytes from the specified byte array to this file, starting at the current file pointer.
Specified by:
write in interface DataOutput
Parameters:
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(b[] )
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6:    private RandomAccessFile raf;
   7:    private File     f;
   8:         ...
   9:       f = file;
  10:       raf = new RandomAccessFile( f, "rw" );
  11:       this.objectOutput = new MyObjectOutputStream( new MyOutputStream() );
  12:         ...
  13:          throws IOException {
  14:          raf.write( ( byte )b );

View Full Code Here
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5:         try {
   6:             RandomAccessFile riff = new RandomAccessFile(file, "rw");
   7: 
   8:         ...
   9:             if (!INTEL)
  10:                 riff.write((byte)'X');

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:   private RandomAccessFile raFile;
   7:   private int bytesPerPixel;
   8:         ...
   9: 
  10:     raFile = new RandomAccessFile(file, "rw");
  11:     raFile.setLength(0);
  12:         ...
  13:     for (int z = 0; z < zDim; z++) {
  14:       raFile.write(dataSignature);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.sql.Connection;
   4:         ...
   5: 
   6:     RandomAccessFile rfile = null;
   7:     try{
   8:         ...
   9:       rfile = new RandomAccessFile(file, "rw");
  10:     } catch(IOException e) {
  11:         ...
  12:     try {
  13:       rfile.write(version.getBytes());

View Full Code Here
   1:                 File file = new File(new File(uploadDir), "form_" + postid + "_" + name);
   2:                 RandomAccessFile raf = null;
   3:                 try {
   4:         ...
   5:                     raf = new RandomAccessFile(file, "rw");
   6:                     if (obj instanceof Vector) {
   7:         ...
   8:                         v = (Vector)obj;
   9:                         raf.write((byte[])v.elementAt(0));
  10:                     } else {
  11:         ...
  12:                         raf.write((byte[])obj);

View Full Code Here

write

public void write(b[] ,
                  int off,
                  int len)
            throws IOException
Writes len bytes from the specified byte array starting at offset off to this file.
Specified by:
write in interface DataOutput
Parameters:
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(b[] ,int off,int len)
   1: {
   2: private RandomAccessFile f;
   3: private boolean isClose;
   4:         ...
   5: 
   6: public RandomOutputStream(RandomAccessFile f, boolean closeRaf)
   7: {
   8:         ...
   9: {
  10:     f.write(b, off, len);
  11: }

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: public class RandomAccessOutputStream extends OutputStream {
   6:     RandomAccessFile raf;
   7: 
   8:         ...
   9:     public RandomAccessOutputStream(RandomAccessFile raf) {
  10:         super();
  11:         ...
  12:     public void write(byte[] b, int off, int len) throws IOException {
  13:         raf.write(b, off, len);

View Full Code Here
   1: import java.io.OutputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:     private RandomAccessFile file;
   7: 
   8:         ...
   9:     public SeekableOutputStream(RandomAccessFile file) {
  10:         if(file == null) {
  11:         ...
  12:     public void write(byte b[], int off, int len) throws IOException {
  13:         file.write(b, off, len);

View Full Code Here
   1: 
   2:     private RandomAccessFile raf;
   3:     
   4:         ...
   5:     public LogOutputStream(RandomAccessFile raf) throws IOException {
   6:     this.raf = raf;
   7:         ...
   8:     public void write(byte b[], int off, int len) throws IOException {
   9:     raf.write(b, off, len);
  10:     }

View Full Code Here
   1: 
   2:     private RandomAccessFile raf;
   3:     
   4:         ...
   5:     public LogOutputStream(RandomAccessFile raf) throws IOException {
   6:     this.raf = raf;
   7:         ...
   8:     public void write(byte b[], int off, int len) throws IOException {
   9:     raf.write(b, off, len);
  10:     }

View Full Code Here

write

public void write(int b)
            throws IOException
Writes the specified byte to this file. The write starts at the current file pointer.
Specified by:
write in interface DataOutput
Parameters:
b - the byte to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(int b)
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6:    private RandomAccessFile raf;
   7:    private File     f;
   8:         ...
   9:       f = file;
  10:       raf = new RandomAccessFile( f, "rw" );
  11:       this.objectOutput = new MyObjectOutputStream( new MyOutputStream() );
  12:         ...
  13:          throws IOException {
  14:          raf.write( ( byte )b );

View Full Code Here
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5:         try {
   6:             RandomAccessFile riff = new RandomAccessFile(file, "rw");
   7: 
   8:         ...
   9:             if (!INTEL)
  10:                 riff.write((byte)'X');

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:   private RandomAccessFile raFile;
   7:   private int bytesPerPixel;
   8:         ...
   9: 
  10:     raFile = new RandomAccessFile(file, "rw");
  11:     raFile.setLength(0);
  12:         ...
  13:     for (int z = 0; z < zDim; z++) {
  14:       raFile.write(dataSignature);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.sql.Connection;
   4:         ...
   5: 
   6:     RandomAccessFile rfile = null;
   7:     try{
   8:         ...
   9:       rfile = new RandomAccessFile(file, "rw");
  10:     } catch(IOException e) {
  11:         ...
  12:     try {
  13:       rfile.write(version.getBytes());

View Full Code Here
   1:                 File file = new File(new File(uploadDir), "form_" + postid + "_" + name);
   2:                 RandomAccessFile raf = null;
   3:                 try {
   4:         ...
   5:                     raf = new RandomAccessFile(file, "rw");
   6:                     if (obj instanceof Vector) {
   7:         ...
   8:                         v = (Vector)obj;
   9:                         raf.write((byte[])v.elementAt(0));
  10:                     } else {
  11:         ...
  12:                         raf.write((byte[])obj);

View Full Code Here

writeBoolean

public final void writeBoolean(boolean v)
            throws IOException
Writes a boolean to the file as a one-byte value. The value true is written out as the value (byte)1; the value false is written out as the value (byte)0. The write starts at the current position of the file pointer.
Specified by:
writeBoolean in interface DataOutput
Parameters:
v - a boolean value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeBoolean(boolean v)
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         raf.writeBoolean(v);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:    {
   6:       r = new RandomAccessFile(f, rw);
   7:       w = new byte[8];
   8:         ...
   9:    {
  10:       r = new RandomAccessFile(f, rw);
  11:       w = new byte[8];
  12:         ...
  13:    {
  14:       r.writeBoolean(v);

View Full Code Here
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6:    private RandomAccessFile raf;
   7:    private File     f;
   8:         ...
   9:       f = file;
  10:       raf = new RandomAccessFile( f, "rw" );
  11:       this.objectOutput = new MyObjectOutputStream( new MyOutputStream() );
  12:         ...
  13:       raf.writeLong( messageID );
  14:       raf.writeBoolean( isTransacted );

View Full Code Here

writeByte

public final void writeByte(int v)
            throws IOException
Writes a byte to the file as a one-byte value. The write starts at the current position of the file pointer.
Specified by:
writeByte in interface DataOutput
Parameters:
v - a byte value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeByte(int v)
   1:     private File lockFile;
   2:     private RandomAccessFile lockRAF;
   3: 
   4:         ...
   5: 
   6:         lockRAF.writeByte(0);
   7: 
   8:         return true;
   9:     }

View Full Code Here
   1:     private File lockFile;
   2:     private RandomAccessFile lockRAF;
   3: 
   4:         ...
   5: 
   6:         lockRAF.writeByte(0);
   7: 
   8:         return true;
   9:     }

View Full Code Here
   1:     private File lockFile;
   2:     private RandomAccessFile lockRAF;
   3: 
   4:         ...
   5: 
   6:         lockRAF.writeByte(0);
   7: 
   8:         return true;
   9:     }

View Full Code Here
   1: 
   2:     public void write(RandomAccessFile raf) throws IOException {
   3: 
   4:         ...
   5:     fieldSize=text.length()+1;
   6:     raf.writeByte(TEXT_INFO);
   7:         ...
   8:     raf.writeByte((byte) fieldSize);
   9:     writeCString(raf,text);
  10:         ...
  11:     fieldSize=date.length()+1;
  12:     raf.writeByte(DATE_INFO);

View Full Code Here
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6:    private RandomAccessFile raf;
   7:    private File     f;
   8:         ...
   9:       f = file;
  10:       raf = new RandomAccessFile( f, "rw" );
  11:       this.objectOutput = new MyObjectOutputStream( new MyOutputStream() );
  12:         ...
  13:       throws IOException {
  14:       raf.writeByte( ADD );

View Full Code Here

writeBytes

public final void writeBytes(String s)
            throws IOException
Writes the string to the file as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits. The write starts at the current position of the file pointer.
Specified by:
writeBytes in interface DataOutput
Parameters:
s - a string of bytes to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeBytes(String s)
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:         File file = new File(webAppDir, CONTEXT_FILE);
   6:         RandomAccessFile ras = new RandomAccessFile(file, "rw");
   7: 
   8:         ...
   9:         ras.seek(length);
  10:         ras.writeBytes("/"+service.getContextPath());
  11:         ...
  12:         ras.writeBytes("\n");

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.Iterator;
   4:         ...
   5:         File file = new File(portalRoot, REGISTRY_FILE);
   6:         RandomAccessFile ras = new RandomAccessFile(file, "rw");
   7: 
   8:         ...
   9:         ras.writeBytes("    <application id=\"" + portletAppDescriptorService.getContextPath() + "\">\r\n");
  10:         ras.writeBytes("        <definition-id>" + portletAppDescriptorService.getContextPath() + "</definition-id>\r\n");
  11: 
  12:         ...
  13:             ras.writeBytes("        <portlet id=\"" + p.getPortletName() + "\">\r\n");
  14:             ras.writeBytes("            <definition-id>" + portletAppDescriptorService.getContextPath()

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.Iterator;
   4:         ...
   5:         File file = new File(portalRoot, REGISTRY_FILE);
   6:         RandomAccessFile ras = new RandomAccessFile(file, "rw");
   7:         long length = ras.length();
   8:         ...
   9:         ras.writeBytes("    <application id=\"" + service.getContextPath() + "\">\n");
  10:         ras.writeBytes("        <definition-id>" + service.getContextPath() + "</definition-id>\n");
  11: 
  12:         ...
  13:             ras.writeBytes("        <portlet id=\"" + p.getPortletName() + "\">\n");
  14:             ras.writeBytes("            <definition-id>" + service.getContextPath()

View Full Code Here
   1: 
   2:     public void write(RandomAccessFile raf) throws IOException {
   3: 
   4:         ...
   5:     raf.writeBytes("MPv4");
   6:         ...
   7:     raf.writeBytes("  ");
   8:     int size=6;
   9:         ...
  10:     raf.writeByte((byte) dictionary_type);
  11:     raf.writeBytes("   ");

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.Hashtable;
   4:         ...
   5:         File lastFile = new File(envHome, files[files.length - 1]);
   6:         RandomAccessFile rw = new RandomAccessFile(lastFile, "rw");
   7: 
   8:         ...
   9:         rw.seek(rw.length()-10);
  10:         rw.writeBytes("000000");
  11:         rw.close();

View Full Code Here

writeChar

public final void writeChar(int v)
            throws IOException
Writes a char to the file as a two-byte value, high byte first. The write starts at the current position of the file pointer.
Specified by:
writeChar in interface DataOutput
Parameters:
v - a char value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeChar(int v)
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         raf.writeChar(v);

View Full Code Here
   1: import java.io.PrintWriter;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:         {
   6:             RandomAccessFile file;
   7:         ...
   8:             file = new RandomAccessFile(exceptionFile, "rw");
   9:         ...
  10:             file.writeChar('t');

View Full Code Here

writeChars

public final void writeChars(String s)
            throws IOException
Writes a string to the file as a sequence of characters. Each character is written to the data output stream as if by the writeChar method. The write starts at the current position of the file pointer.
Specified by:
writeChars in interface DataOutput
Parameters:
s - a String value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeChars(String s)
   1: 
   2:     RandomAccessFile output = null;
   3: 
   4:         ...
   5:     {
   6:       output = new RandomAccessFile( args[1], "rw" );
   7:     }
   8:     catch ( IOException e ) {
   9:       e.printStackTrace();

View Full Code Here
   1:     }
   2:     public UserInfo5 read(RandomAccessFile raf) throws IOException {
   3:         char[] name = new char[16];
   4:         ...
   5:     }
   6:     public void write(RandomAccessFile raf,UserInfo5 ui5) throws IOException {
   7:         
   8:         ...
   9:         raf.writeChars(ui5.getName());
  10:         ...
  11:         raf.writeChars(ui5.getDep());

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         raf.writeChars(s);

View Full Code Here

writeDouble

public final void writeDouble(double v)
            throws IOException
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the file as an eight-byte quantity, high byte first. The write starts at the current position of the file pointer.
Specified by:
writeDouble in interface DataOutput
Parameters:
v - a double value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeDouble(double v)
   1:   static void display() throws IOException {
   2:     RandomAccessFile rf = new RandomAccessFile(file, "r");
   3:     for(int i = 0; i < 7; i++)
   4:         ...
   5:   throws IOException {
   6:     RandomAccessFile rf = new RandomAccessFile(file, "rw");
   7:     for(int i = 0; i < 7; i++)
   8:         ...
   9:       rf.writeDouble(i*1.414);
  10:     rf.writeUTF("The end of the file");
  11:         ...
  12:     rf.seek(5*8);
  13:     rf.writeDouble(47.0001);

View Full Code Here
   1:             DataOutputStream out2=new DataOutputStream(new FileOutputStream("Data.txt"));
   2:             out2.writeDouble(3.325453);
   3:             out2.writeChars("That was pi\n");
   4:         ...
   5:         
   6:         RandomAccessFile rf=new RandomAccessFile("rtest.dat","rw");
   7:         for(int i=0;i<10;i++)
   8:         ...
   9:         rf.writeDouble(i*1.414);
  10:         rf.close();
  11:         ...
  12:         
  13:         rf=new RandomAccessFile("rtest.dat","rw");

View Full Code Here
   1:           "Here's the value of pi: \n");
   2:         out2.writeDouble(3.14159);
   3:         out2.close();
   4:         ...
   5: 
   6:       RandomAccessFile rf =
   7:         ...
   8:         new RandomAccessFile("rtest.dat", "rw");
   9:       for(int i = 0; i < 10; i++)
  10:         ...
  11:         rf.writeDouble(i*1.414);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         raf.writeDouble(v);

View Full Code Here

writeFloat

public final void writeFloat(float v)
            throws IOException
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the file as a four-byte quantity, high byte first. The write starts at the current position of the file pointer.
Specified by:
writeFloat in interface DataOutput
Parameters:
v - a float value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeFloat(float v)
   1: 
   2:     public void write(RandomAccessFile raf) throws IOException {
   3: 
   4:         ...
   5:     raf.writeByte((byte) fieldSize);
   6:     raf.writeFloat(sampling_freq);
   7:         ...
   8:     raf.writeFloat(points_per_microvolt);
   9:     raf.writeInt(number_of_chanels_in_file);
  10:         ...
  11:     raf.writeByte((byte) fieldSize);
  12:     raf.writeFloat(energy_percent);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         raf.writeFloat(v);

View Full Code Here

writeInt

public final void writeInt(int v)
            throws IOException
Writes an int to the file as four bytes, high byte first. The write starts at the current position of the file pointer.
Specified by:
writeInt in interface DataOutput
Parameters:
v - an int to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeInt(int v)
   1:   public static void main(String[] args) throws IOException {
   2:     RandomAccessFile raf = new RandomAccessFile("Exercise18_8.dat", "rw");
   3: 
   4:         ...
   5:     raf.seek(0);
   6:     raf.writeInt(++count);
   7:     System.out.println("Current count is " + count);
   8:     raf.close();
   9:   }

View Full Code Here
   1:         for(int i = 0; i < numOfInts; i++)
   2:           dos.writeInt(i);
   3:         dos.close();
   4:         ...
   5:         FileChannel fc =
   6:           new RandomAccessFile("temp.tmp", "rw")
   7:           .getChannel();
   8:         ...
   9:       public void test() throws IOException {
  10:         RandomAccessFile raf = new RandomAccessFile(
  11:           new File("temp.tmp"), "rw");
  12:         ...
  13:         raf.writeInt(1);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: public class BlocksIndexOutput extends IndexOutput {
   6:     protected RandomAccessFile indexOut;
   7:     protected int blockNum;
   8:         ...
   9:         indexOut.writeUTF(IIndexConstants.SIGNATURE);
  10:         indexOut.writeInt(blockNum);
  11:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.nio.channels.FileChannel;
   4:         ...
   5: 
   6:     private RandomAccessFile lockFileOpen;
   7:     private FileChannel lockFileChannel;
   8:         ...
   9:             {
  10:                 lockFileOpen = new RandomAccessFile((File) this, "rw");
  11:                 lockFileChannel = lockFileOpen.getChannel();
  12:         ...
  13:                 {    
  14:                     lockFileOpen.writeInt(EXCLUSIVE_FILE_LOCK);

View Full Code Here
   1:     public void persist(DataOutputStream dos) throws IOException {
   2:         dos.writeInt(firstPageNo);
   3:         ...
   4:         dos.writeInt(lastPageNo);
   5:         ...
   6:         dos.writeInt(sizeInBytes);
   7:         dos.writeByte (hasUpdates? 0x01 : 0x00);
   8:         ...
   9: 
  10:     private RandomAccessFile randomFile = null;

View Full Code Here

writeLong

public final void writeLong(long v)
            throws IOException
Writes a long to the file as eight bytes, high byte first. The write starts at the current position of the file pointer.
Specified by:
writeLong in interface DataOutput
Parameters:
v - a long to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeLong(long v)
   1:   public static void main(String args[])throws IOException{
   2:      RandomAccessFile rf=new RandomAccessFile("D:\\test.dat","rw");
   3:      for(int i=0;i<10;i++)
   4:         ...
   5:        rf.writeLong(i*1000);
   6: 
   7:         ...
   8:      rf.writeLong(1234);

View Full Code Here
   1:                 int data = 123;
   2:                RandomAccessFile raf = new RandomAccessFile("datafile", "rw");
   3:         ...
   4:                raf.writeLong(0); 
   5:                 raf.writeChars("hello world");
   6:         ...
   7:                 raf.writeUTF("hello java");
   8:                raf.writeLong(dataPosition);
   9:                System.out.println("WRITE FILE SUCCESS");

View Full Code Here
   1:   private long count = 0;
   2:   private RandomAccessFile inout = null;
   3: 
   4:         ...
   5:     try {
   6:       inout = new RandomAccessFile("Exercise26_3.dat", "rw");
   7:       if (inout.length() == 0)
   8:         ...
   9:       inout.seek(0);
  10:       inout.writeLong(count);
  11:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: class FileDataBlock {
   6:     private RandomAccessFile dataBlock;
   7:     private File file;
   8:         ...
   9:         this.maxSize = maxSize;
  10:         this.dataBlock = new RandomAccessFile(file, "rw");
  11:         if (dataBlock.length() > 0) {
  12:         ...
  13:         else {
  14:             dataBlock.writeLong(0);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: class FileDataBlock {
   6:     private RandomAccessFile dataBlock;
   7:     private File file;
   8:         ...
   9:         this.maxSize = maxSize;
  10:         this.dataBlock = new RandomAccessFile(file, "rw");
  11:         if (dataBlock.length() > 0) {
  12:         ...
  13:         else {
  14:             dataBlock.writeLong(0);

View Full Code Here

writeShort

public final void writeShort(int v)
            throws IOException
Writes a short to the file as two bytes, high byte first. The write starts at the current position of the file pointer.
Specified by:
writeShort in interface DataOutput
Parameters:
v - a short to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeShort(int v)
   1: import java.io.File;
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5:         try {
   6:             RandomAccessFile riff = new RandomAccessFile(file, "rw");
   7: 
   8:             int len = (int) riff.length() - 8;
   9:             int bitrate = 1411200;

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: 
   6:         RandomAccessFile ts = new RandomAccessFile(name, "rw");
   7: 
   8:         ...
   9:         ts.seek(0);
  10:         ts.writeShort((short)event[2]);
  11:         ts.writeByte((byte)datum.get(Calendar.HOUR_OF_DAY));
  12:         ...
  13:         ts.writeByte((byte)datum.get(Calendar.MINUTE));
  14:         ts.writeShort((short)event[2]);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.Arrays;
   4:         ...
   5:                 if (fileHeader.getFixedKeyLen() < 0)
   6:                     os.writeShort(values[i].getLength());
   7:                 values[i].streamTo(os);
   8:         ...
   9:                 if (fileHeader.getFixedKeyLen() < 0)
  10:                     os.writeShort(values[i].getLength());
  11:                 values[i].streamTo(os);
  12:         ...
  13: 
  14:         public void read(RandomAccessFile raf) throws IOException {

View Full Code Here
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5:     {
   6:         RandomAccessFile aiff = new RandomAccessFile(file,"rw");
   7: 
   8:         int len = (int)(aiff.length() - 8);

View Full Code Here

writeUTF

public final void writeUTF(String str)
            throws IOException
Writes a string to the file using modified UTF-8 encoding in a machine-independent manner.

First, two bytes are written to the file, starting at the current file pointer, as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for each character.

Specified by:
writeUTF in interface DataOutput
Parameters:
str - a string to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeUTF(String str)
   1: 
   2: import java.io.RandomAccessFile;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:    public final void writeData(final RandomAccessFile ra, final Object userData) throws IOException, XmlBlasterException {
   7:       
   8:         ...
   9: 
  10:       ra.writeUTF(cont.method.getMethodName());
  11:       
  12:         ...
  13: 
  14:             ra.writeUTF(cont.cbSessionId);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: public class BlocksIndexOutput extends IndexOutput {
   6:     protected RandomAccessFile indexOut;
   7:     protected int blockNum;
   8:         ...
   9:         indexOut.seek(0);
  10:         indexOut.writeUTF(IIndexConstants.SIGNATURE);
  11:         indexOut.writeInt(blockNum);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5: {
   6:     final private RandomAccessFile raf;
   7:     final private InputStream rafis;
   8:         ...
   9:         {
  10:             raf = new RandomAccessFile(localFile, modes.toString());
  11:             rafis = new InputStream()
  12:         ...
  13:     {
  14:         raf.writeUTF(str);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: 
   4:         ...
   5:    {
   6:       r = new RandomAccessFile(f, rw);
   7:       w = new byte[8];
   8:         ...
   9:    {
  10:       r = new RandomAccessFile(f, rw);
  11:       w = new byte[8];
  12:         ...
  13:    {
  14:       r.writeUTF(str);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.RandomAccessFile;
   3: import java.util.ArrayList;
   4:         ...
   5:     }
   6:     public void read(RandomAccessFile raf) throws IOException {
   7:         numFiles= raf.readInt();
   8:         ...
   9:     }
  10:     public void write(RandomAccessFile raf) throws IOException {
  11:         raf.writeInt(numFiles);
  12:         ...
  13:             FirstFileInBlock entry= (FirstFileInBlock) firstFilesInBlocks.get(i);
  14:             raf.writeUTF(entry.indexedFile.getPath());

View Full Code Here