当前位置: 首页>>代码示例>>Java>>正文


Java DbException.convertToIOException方法代码示例

本文整理汇总了Java中org.h2.message.DbException.convertToIOException方法的典型用法代码示例。如果您正苦于以下问题:Java DbException.convertToIOException方法的具体用法?Java DbException.convertToIOException怎么用?Java DbException.convertToIOException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.message.DbException的用法示例。


在下文中一共展示了DbException.convertToIOException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copy

import org.h2.message.DbException; //导入方法依赖的package包/类
public static long copy(InputStream in, ByteBuffer out, long length)
        throws IOException {
    try {
        long copied = 0;
        int len = (int) Math.min(length, Constants.IO_BUFFER_SIZE);
        byte[] buffer = new byte[len];
        while (length > 0) {
            len = in.read(buffer, 0, len);
            if (len < 0) {
                break;
            }
            if (out != null) {
                out.put(buffer, 0, len);
            }
            copied += len;
            length -= len;
            len = (int) Math.min(length, Constants.IO_BUFFER_SIZE);
        }
        return copied;
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:24,代码来源:ByteBufferTool.java

示例2: copy

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Copy all data from the input stream to the output stream. Both streams
 * are kept open.
 *
 * @param in the input stream
 * @param out the output stream (null if writing is not required)
 * @param length the maximum number of bytes to copy
 * @return the number of bytes copied
 */
public static long copy(InputStream in, OutputStream out, long length)
        throws IOException {
    try {
        long copied = 0;
        int len = (int) Math.min(length, Constants.IO_BUFFER_SIZE);
        byte[] buffer = new byte[len];
        while (length > 0) {
            len = in.read(buffer, 0, len);
            if (len < 0) {
                break;
            }
            if (out != null) {
                out.write(buffer, 0, len);
            }
            copied += len;
            length -= len;
            len = (int) Math.min(length, Constants.IO_BUFFER_SIZE);
        }
        return copied;
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:33,代码来源:IOUtils.java

示例3: copyAndCloseInput

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Copy all data from the reader to the writer and close the reader.
 * Exceptions while closing are ignored.
 *
 * @param in the reader
 * @param out the writer (null if writing is not required)
 * @param length the maximum number of bytes to copy
 * @return the number of characters copied
 */
public static long copyAndCloseInput(Reader in, Writer out, long length)
        throws IOException {
    try {
        long copied = 0;
        int len = (int) Math.min(length, Constants.IO_BUFFER_SIZE);
        char[] buffer = new char[len];
        while (length > 0) {
            len = in.read(buffer, 0, len);
            if (len < 0) {
                break;
            }
            if (out != null) {
                out.write(buffer, 0, len);
            }
            length -= len;
            len = (int) Math.min(length, Constants.IO_BUFFER_SIZE);
            copied += len;
        }
        return copied;
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    } finally {
        in.close();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:35,代码来源:IOUtils.java

示例4: readBytesAndClose

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Read a number of bytes from an input stream and close the stream.
 *
 * @param in the input stream
 * @param length the maximum number of bytes to read, or -1 to read until
 *            the end of file
 * @return the bytes read
 */
public static byte[] readBytesAndClose(InputStream in, int length)
        throws IOException {
    try {
        if (length <= 0) {
            length = Integer.MAX_VALUE;
        }
        int block = Math.min(Constants.IO_BUFFER_SIZE, length);
        ByteArrayOutputStream out = new ByteArrayOutputStream(block);
        copy(in, out, length);
        return out.toByteArray();
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    } finally {
        in.close();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:IOUtils.java

示例5: readFully

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Try to read the given number of bytes to the buffer. This method reads
 * until the maximum number of bytes have been read or until the end of
 * file.
 *
 * @param in the input stream
 * @param buffer the output buffer
 * @param max the number of bytes to read at most
 * @return the number of bytes read, 0 meaning EOF
 */
public static int readFully(InputStream in, byte[] buffer, int max)
        throws IOException {
    try {
        int result = 0, len = Math.min(max, buffer.length);
        while (len > 0) {
            int l = in.read(buffer, result, len);
            if (l < 0) {
                break;
            }
            result += l;
            len -= l;
        }
        return result;
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:IOUtils.java

示例6: getInputStream

import org.h2.message.DbException; //导入方法依赖的package包/类
@Override
public InputStream getInputStream(ValueLobDb lob, byte[] hmac,
        long byteCount) throws IOException {
    try {
        init();
        assertNotHolds(conn.getSession());
        // see locking discussion at the top
        synchronized (database) {
            synchronized (conn.getSession()) {
                long lobId = lob.getLobId();
                return new LobInputStream(lobId, byteCount);
            }
        }
    } catch (SQLException e) {
        throw DbException.convertToIOException(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:LobStorageBackend.java

示例7: fillBuffer

import org.h2.message.DbException; //导入方法依赖的package包/类
private void fillBuffer() throws IOException {
            if (buffer != null && bufferPos < buffer.length) {
                return;
            }
            if (remainingBytes <= 0) {
                return;
            }
if (lobMapIndex >= lobMapBlocks.length) {
    System.out.println("halt!");
}
            try {
                buffer = readBlock(lobMapBlocks[lobMapIndex]);
                lobMapIndex++;
                bufferPos = 0;
            } catch (SQLException e) {
                throw DbException.convertToIOException(e);
            }
        }
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:19,代码来源:LobStorageBackend.java

示例8: read

import org.h2.message.DbException; //导入方法依赖的package包/类
@Override
public int read(byte[] buff, int off, int length) throws IOException {
    if (length == 0) {
        return 0;
    }
    length = (int) Math.min(length, remainingBytes);
    if (length == 0) {
        return -1;
    }
    try {
        length = handler.readLob(lob, hmac, pos, buff, off, length);
    } catch (DbException e) {
        throw DbException.convertToIOException(e);
    }
    remainingBytes -= length;
    if (length == 0) {
        return -1;
    }
    pos += length;
    return length;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:LobStorageRemoteInputStream.java

示例9: createLob

import org.h2.message.DbException; //导入方法依赖的package包/类
private ValueLobDb createLob(InputStream in, int type) throws IOException {
    byte[] streamStoreId;
    try {
        streamStoreId = streamStore.put(in);
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    }
    long lobId = generateLobId();
    long length = streamStore.length(streamStoreId);
    int tableId = LobStorageFrontend.TABLE_TEMP;
    Object[] value = new Object[] { streamStoreId, tableId, length, 0 };
    lobMap.put(lobId, value);
    Object[] key = new Object[] { streamStoreId, lobId };
    refMap.put(key, Boolean.TRUE);
    ValueLobDb lob = ValueLobDb.create(
            type, database, tableId, lobId, null, length);
    if (TRACE) {
        trace("create " + tableId + "/" + lobId);
    }
    return lob;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:LobStorageMap.java

示例10: getKeyStoreBytes

import org.h2.message.DbException; //导入方法依赖的package包/类
private static byte[] getKeyStoreBytes(KeyStore store, String password)
        throws IOException {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    try {
        store.store(bout, password.toCharArray());
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    }
    return bout.toByteArray();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:11,代码来源:CipherFactory.java

示例11: setKeystore

import org.h2.message.DbException; //导入方法依赖的package包/类
private static void setKeystore() throws IOException {
    Properties p = System.getProperties();
    if (p.getProperty(KEYSTORE_KEY) == null) {
        String fileName = KEYSTORE;
        byte[] data = getKeyStoreBytes(getKeyStore(
                KEYSTORE_PASSWORD), KEYSTORE_PASSWORD);
        boolean needWrite = true;
        if (FileUtils.exists(fileName) && FileUtils.size(fileName) == data.length) {
            // don't need to overwrite the file if it did not change
            InputStream fin = FileUtils.newInputStream(fileName);
            byte[] now = IOUtils.readBytesAndClose(fin, 0);
            if (now != null && Arrays.equals(data, now)) {
                needWrite = false;
            }
        }
        if (needWrite) {
            try {
                OutputStream out = FileUtils.newOutputStream(fileName, false);
                out.write(data);
                out.close();
            } catch (Exception e) {
                throw DbException.convertToIOException(e);
            }
        }
        String absolutePath = FileUtils.toRealPath(fileName);
        System.setProperty(KEYSTORE_KEY, absolutePath);
    }
    if (p.getProperty(KEYSTORE_PASSWORD_KEY) == null) {
        System.setProperty(KEYSTORE_PASSWORD_KEY, KEYSTORE_PASSWORD);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:32,代码来源:CipherFactory.java

示例12: fillBuffer

import org.h2.message.DbException; //导入方法依赖的package包/类
private void fillBuffer() throws IOException {
    if (buffer != null && pos < bufferLength) {
        return;
    }
    int len = readInt();
    if (decompress == null) {
        // EOF
        this.bufferLength = 0;
    } else if (len < 0) {
        len = -len;
        buffer = ensureSize(buffer, len);
        readFully(buffer, len);
        this.bufferLength = len;
    } else {
        inBuffer = ensureSize(inBuffer, len);
        int size = readInt();
        readFully(inBuffer, len);
        buffer = ensureSize(buffer, size);
        try {
            decompress.expand(inBuffer, 0, len, buffer, 0, size);
        } catch (ArrayIndexOutOfBoundsException e) {
            DbException.convertToIOException(e);
        }
        this.bufferLength = size;
    }
    pos = 0;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:LZFInputStream.java

示例13: initWrite

import org.h2.message.DbException; //导入方法依赖的package包/类
private void initWrite() throws IOException {
    if (output == null) {
        try {
            OutputStream out = FileUtils.newOutputStream(fileName, false);
            out = new BufferedOutputStream(out, Constants.IO_BUFFER_SIZE);
            output = new BufferedWriter(new OutputStreamWriter(out, characterSet));
        } catch (Exception e) {
            close();
            throw DbException.convertToIOException(e);
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:13,代码来源:Csv.java

示例14: skipFully

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Skip a number of bytes in an input stream.
 *
 * @param in the input stream
 * @param skip the number of bytes to skip
 * @throws EOFException if the end of file has been reached before all bytes
 *             could be skipped
 * @throws IOException if an IO exception occurred while skipping
 */
public static void skipFully(InputStream in, long skip) throws IOException {
    try {
        while (skip > 0) {
            long skipped = in.skip(skip);
            if (skipped <= 0) {
                throw new EOFException();
            }
            skip -= skipped;
        }
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:IOUtils.java

示例15: copyAndClose

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Copy all data from the input stream to the output stream and close both
 * streams. Exceptions while closing are ignored.
 *
 * @param in the input stream
 * @param out the output stream
 * @return the number of bytes copied
 */
public static long copyAndClose(InputStream in, OutputStream out)
        throws IOException {
    try {
        long len = copyAndCloseInput(in, out);
        out.close();
        return len;
    } catch (Exception e) {
        throw DbException.convertToIOException(e);
    } finally {
        closeSilently(out);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:21,代码来源:IOUtils.java


注:本文中的org.h2.message.DbException.convertToIOException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。