Code example for RandomAccessFile

Methods: lengthseek

0
		private RandomAccessFile f;
		private long ptr; // relative to startAt
 
		MyInputStream() throws IOException { 
			try { 
				this.f = new RandomAccessFile(file, "r");
				f.seek(startAt);
				if(f.length() < (startAt + length))
					throw new ReadOnlyFileSliceBucketException("File truncated? Length " + f.length() + " but start at " + startAt + " for " + length + " bytes");
				ptr = 0;
			} catch(FileNotFoundException e) {
				throw new ReadOnlyFileSliceBucketException(e);
			} 
		} 
 
		@Override 
		public int read() throws IOException { 
			if(ptr >= length)
				return -1; 
			int x = f.read();
			if(x != -1)