Examples of RandomAccessStream


Examples of com.caucho.vfs.RandomAccessStream

  {
    RandomAccessWrapper wrapper = openRowFile(true);
    boolean isPriority = true;

    try {
      RandomAccessStream file = wrapper.getFile();

      _fileSize = file.getLength();
    } finally {
      closeRowFile(wrapper, isPriority);
    }
  }
View Full Code Here

Examples of com.caucho.vfs.RandomAccessStream

  {
    boolean isPriority = false;
    RandomAccessWrapper wrapper = openRowFile(isPriority);

    try {
      RandomAccessStream is = wrapper.getFile();

      long blockAddress = blockId & BlockStore.BLOCK_MASK;

      if (blockAddress < 0 || _fileSize < blockAddress + length) {
        throw new IllegalStateException(L.l("block at 0x{0} is invalid for file {1} (length 0x{2})",
                                            Long.toHexString(blockAddress),
                                            _path,
                                            Long.toHexString(_fileSize)));
      }

      // System.out.println("READ: " + Long.toHexString(blockAddress));
      int readLen = is.read(blockAddress, buffer, offset, length);

      if (readLen < 0) {
        throw new IllegalStateException("Error reading " + is + " for block " + Long.toHexString(blockAddress) + " result=" + readLen);
      }
View Full Code Here

Examples of com.caucho.vfs.RandomAccessStream

   * Implements the EnvCleanup interface.
   */
  public void cleanup()
  {
    try {
      RandomAccessStream ras = _stream;
      _stream = null;

      if (ras != null) {
        ras.close();

        if (_temporary)
          _path.remove();
      }
    } catch (IOException e) {
View Full Code Here

Examples of com.caucho.vfs.RandomAccessStream

   * Implements the EnvCleanup interface.
   */
  public void cleanup()
  {
    try {
      RandomAccessStream ras = _stream;
      _stream = null;

      if (ras != null) {
        ras.close();

        if (_temporary)
          _path.remove();
      }
    } catch (IOException e) {
View Full Code Here

Examples of com.sun.midp.io.j2me.storage.RandomAccessStream

        Vector CSRs = new Vector();

      String storeName = File.getStorageRoot(
      Constants.INTERNAL_STORAGE_ID) + CSR_ID_FILE;
      RandomAccessStream storage =
                new RandomAccessStream(classSecurityToken);
        DataInputStream dis;

        try {
            storage.connect(storeName, Connector.READ);
            dis = new DataInputStream(storage.openInputStream());
        } catch (IOException ioe) {

            try {
                storage.connect(storeName, Connector.READ_WRITE);
                DataOutputStream dos = storage.openDataOutputStream();
                dos.writeInt(0);
                dos.flush();
                dos.close();
                dis = new DataInputStream(storage.openInputStream());
            } catch (IOException openwe) {
                return CSRs;
            }
            try {
                storage.disconnect();
            } catch (IOException e) {} // ignored
            return CSRs;
        }

        try {
            int count = dis.readInt();
            while (count-- > 0) {
                byte[] id = new byte[20];
                dis.read(id, 0, 20);
                CSRs.addElement(id);
            }
        } catch (IOException e) {} // ignored
        finally {
            try {
                storage.disconnect();
            } catch (IOException e) {} // ignored
        }
        return CSRs;
    }
View Full Code Here

Examples of com.sun.midp.io.j2me.storage.RandomAccessStream

            return;
        }

        String storeName = File.getStorageRoot(
      Constants.INTERNAL_STORAGE_ID) + CSR_ID_FILE;
        RandomAccessStream storage =
                new RandomAccessStream(classSecurityToken);
        DataOutputStream dos;

        try {
            storage.connect(storeName, Connector.WRITE);
            dos = storage.openDataOutputStream();
            int len = CSRs.size();
            dos.writeInt(len);
            for (int i = 0; i < len; i++) {
                dos.write((byte[]) CSRs.elementAt(i));
            }
            dos.flush();
            dos.close();
            storage.truncate(4 + len * 20);
        } catch (IOException openwe) {} // ignored
        finally {
            try {
                storage.disconnect();
            } catch (IOException e) {} // ignored
        }
    }
View Full Code Here

Examples of com.sun.midp.io.j2me.storage.RandomAccessStream

        if (state.exception != null) {
            return;
        }

        try {
            state.storage = new RandomAccessStream();

            state.installInfo.authPath =
                verifier.verifyJar(state.storage, info.jarFilename);

            if (state.listener != null) {
View Full Code Here

Examples of com.sun.midp.io.j2me.storage.RandomAccessStream

     *
     * @exception IOException is thrown if any error prevents the download
     *            of the JAD
     */
    protected byte[] downloadJAD() throws IOException {
        RandomAccessStream jadInputStream;
        ByteArrayOutputStream bos = new ByteArrayOutputStream(CHUNK_SIZE);
        String jadFilename = getUrlPath(state.localJadUrl);

        state.beginTransferDataStatus = DOWNLOADING_JAD;
        state.transferStatus = DOWNLOADED_1K_OF_JAD;

        jadInputStream = new RandomAccessStream();
        jadInputStream.connect(jadFilename, Connector.READ);

        transferData(jadInputStream.openInputStream(), bos, CHUNK_SIZE);

        jadInputStream.close();

        return bos.toByteArray();
    }
View Full Code Here

Examples of com.sun.midp.io.j2me.storage.RandomAccessStream

     * @exception IOException is thrown if any error prevents the download
     *   of the JAR
     */
    protected int downloadJAR(String filename) throws IOException {
        int jarSize;
        RandomAccessStream jarInputStream, jarOutputStream;
        String jarFilename = getUrlPath(state.localJarUrl);

        // Open source (jar) file
        jarInputStream = new RandomAccessStream();
        jarInputStream.connect(jarFilename, Connector.READ);

        // Open destination (temporary) file
        jarOutputStream = new RandomAccessStream();
        jarOutputStream.connect(filename,
                                RandomAccessStream.READ_WRITE_TRUNCATE);

        // transfer data
        state.beginTransferDataStatus = DOWNLOADING_JAR;
        state.transferStatus = DOWNLOADED_1K_OF_JAR;

        jarSize = transferData(jarInputStream.openInputStream(),
                               jarOutputStream.openOutputStream(), CHUNK_SIZE);

        jarInputStream.close();

        return jarSize;
    }
View Full Code Here

Examples of com.sun.midp.io.j2me.storage.RandomAccessStream

        if (state.exception != null) {
            return;
        }

        try {
            state.storage = new RandomAccessStream();

            state.installInfo.authPath =
                verifier.verifyJar(state.storage, info.jarFilename);

            if (state.listener != null) {
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.