Package java.io

Examples of java.io.RandomAccessFile.seek()


                    trace("setLength " + pos);
                    f.setFileLength(pos);
                    ra.setLength(pos);
                    if (ra.getFilePointer() > pos) {
                        f.seek(0);
                        ra.seek(0);
                    }
                    buff.append("setLength " + pos + "\n");
                    break;
                }
                case 3: {
View Full Code Here


        Assertion.isNotNull(entry);
      FileInfo fileInfo = entry.getValue();
      synchronized (fileInfo) {
        try {
          RandomAccessFile fileAccess = fileInfo.open();
              fileAccess.seek(fileOffset - entry.getKey());
              return fileAccess.read(b, offSet, length);
        } catch (IOException e) {
          throw new TeiidComponentException(e, QueryPlugin.Util.getString("FileStoreageManager.error_reading", fileInfo.file.getAbsoluteFile())); //$NON-NLS-1$
        } finally {
          fileInfo.close();
View Full Code Here

      synchronized (fileInfo) {
            try {
              RandomAccessFile fileAccess = fileInfo.open();
                long pointer = fileAccess.length();
                fileAccess.setLength(pointer + length);
                fileAccess.seek(pointer);
                fileAccess.write(bytes, offset, length);
            } catch(IOException e) {
                throw new TeiidComponentException(e, QueryPlugin.Util.getString("FileStoreageManager.error_reading", fileInfo.file.getAbsoluteFile())); //$NON-NLS-1$
            } finally {
              fileInfo.close();
View Full Code Here

        }
        RandomAccessFile write = new RandomAccessFile(file, "rws");
        // RandomAccessFile write = new RandomAccessFile(file, "rwd");
        int fileSize = 10 * 1024 * 1024;
        IOUtils.setLength(write, fileSize);
        write.seek(0);
        int i = 0;
        FileDescriptor fd = write.getFD();
        while (true) {
            if (write.getFilePointer() >= fileSize) {
                break;
View Full Code Here

        byte[] data = { 0 };
        file.write(data);
        int i = 0;
        if (flush) {
            for (;; i++) {
                file.seek(0);
                file.write(data);
                fd.sync();
                if ((i & 15) == 0) {
                    long time = System.currentTimeMillis() - start;
                    if (time > 5000) {
View Full Code Here

                    }
                }
            }
        } else {
            for (;; i++) {
                file.seek(0);
                file.write(data);
                if ((i & 1023) == 0) {
                    long time = System.currentTimeMillis() - start;
                    if (time > 5000) {
                        break;
View Full Code Here

             
              if ( buffer == null ){
             
                buffer = new byte[ limit ];

                raf.seek( pos );
             
                read_length =  raf.read( buffer );
               
                if ( read_length != limit ){
                 
View Full Code Here

          if ( raf != null ){
           
            try{
              synchronized( TranscodePipe.this ){

                raf.seek( 0 );
             
                raf.read( new byte[1] );
              }
            }catch( Throwable f ){
             
View Full Code Here

            //read the bytes
            raf = new RandomAccessFile( jar_file, "r" );
            byte[] jarBytes = new byte[size.intValue()];

            raf.seek(offset.intValue());
            raf.read( jarBytes );


            //Build the URL.
            Map request = new HashMap();
View Full Code Here

                    ShxInputStream pis = new ShxInputStream(is);
                    int[][] index = pis.getIndex();
                    is.close();
                   
                    RandomAccessFile raf = new RandomAccessFile(shape + ".shp", "rw");
                    raf.seek(24);
                    int contentLength = raf.readInt();
                   
                    int indexedContentLength = index[0][index[0].length - 1] + index[1][index[1].length - 1];
                   
                    if (contentLength != indexedContentLength) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.