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


Java IOUtil.closeQuietly方法代码示例

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


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

示例1: writeStreamAndCloseIn

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
private void writeStreamAndCloseIn(OutputStream out, InputStream in) throws IOException {
    if (out instanceof CounterOutputStream) {
        ((CounterOutputStream) out).addStream(in);
    } else {
        try {
            int len;
            byte[] buf = new byte[1024];
            while ((len = in.read(buf)) >= 0) {
                out.write(buf, 0, len);
                current += len;
                if (callBackHandler != null && !callBackHandler.updateProgress(total, current, false)) {
                    throw new Callback.CancelledException("upload stopped!");
                }
            }
        } finally {
            IOUtil.closeQuietly(in);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:MultipartBody.java

示例2: writeTo

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
@Override
public void writeTo(OutputStream out) throws IOException {
    if (callBackHandler != null && !callBackHandler.updateProgress(total, current, true)) {
        throw new Callback.CancelledException("upload stopped!");
    }

    byte[] buffer = new byte[1024];
    try {
        int len = 0;
        while ((len = content.read(buffer)) != -1) {
            out.write(buffer, 0, len);
            current += len;
            if (callBackHandler != null && !callBackHandler.updateProgress(total, current, false)) {
                throw new Callback.CancelledException("upload stopped!");
            }
        }
        out.flush();

        if (callBackHandler != null) {
            callBackHandler.updateProgress(total, total, true);
        }
    } finally {
        IOUtil.closeQuietly(content);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:InputStreamBody.java

示例3: findFirst

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
public T findFirst() throws DbException {
    if (!table.tableIsExist()) return null;

    this.limit(1);
    Cursor cursor = table.getDb().execQuery(this.toString());
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                return CursorUtils.getEntity(table, cursor);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Selector.java

示例4: findAll

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
public List<T> findAll() throws DbException {
    if (!table.tableIsExist()) return null;

    List<T> result = null;
    Cursor cursor = table.getDb().execQuery(this.toString());
    if (cursor != null) {
        try {
            result = new ArrayList<T>();
            while (cursor.moveToNext()) {
                T entity = CursorUtils.getEntity(table, cursor);
                result.add(entity);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:Selector.java

示例5: findById

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T findById(Class<T> entityType, Object idValue) throws DbException {
    TableEntity<T> table = this.getTable(entityType);
    if (!table.tableIsExist()) return null;

    Selector selector = Selector.from(table).where(table.getId().getName(), "=", idValue);

    String sql = selector.limit(1).toString();
    Cursor cursor = execQuery(sql);
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                return CursorUtils.getEntity(table, cursor);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DbManagerImpl.java

示例6: findDbModelFirst

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
@Override
public DbModel findDbModelFirst(SqlInfo sqlInfo) throws DbException {
    Cursor cursor = execQuery(sqlInfo);
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                return CursorUtils.getDbModel(cursor);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DbManagerImpl.java

示例7: findDbModelAll

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
@Override
public List<DbModel> findDbModelAll(SqlInfo sqlInfo) throws DbException {
    List<DbModel> dbModelList = new ArrayList<DbModel>();

    Cursor cursor = execQuery(sqlInfo);
    if (cursor != null) {
        try {
            while (cursor.moveToNext()) {
                dbModelList.add(CursorUtils.getDbModel(cursor));
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return dbModelList;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DbManagerImpl.java

示例8: getLastAutoIncrementId

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
private long getLastAutoIncrementId(String tableName) throws DbException {
    long id = -1;
    Cursor cursor = execQuery("SELECT seq FROM sqlite_sequence WHERE name='" + tableName + "' LIMIT 1");
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                id = cursor.getLong(0);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return id;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DbManagerImpl.java

示例9: tableIsExist

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
public boolean tableIsExist() throws DbException {
    if (this.isCheckedDatabase()) {
        return true;
    }

    Cursor cursor = db.execQuery("SELECT COUNT(*) AS c FROM sqlite_master WHERE type='table' AND name='" + name + "'");
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                int count = cursor.getInt(0);
                if (count > 0) {
                    this.setCheckedDatabase(true);
                    return true;
                }
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }

    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:TableEntity.java

示例10: findFirst

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
public DbModel findFirst() throws DbException {
    TableEntity<?> table = selector.getTable();
    if (!table.tableIsExist()) return null;

    this.limit(1);
    Cursor cursor = table.getDb().execQuery(this.toString());
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                return CursorUtils.getDbModel(cursor);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DbModelSelector.java

示例11: findAll

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
public List<DbModel> findAll() throws DbException {
    TableEntity<?> table = selector.getTable();
    if (!table.tableIsExist()) return null;

    List<DbModel> result = null;

    Cursor cursor = table.getDb().execQuery(this.toString());
    if (cursor != null) {
        try {
            result = new ArrayList<DbModel>();
            while (cursor.moveToNext()) {
                DbModel entity = CursorUtils.getDbModel(cursor);
                result.add(entity);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DbModelSelector.java

示例12: getThumbCache

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
/**
 * 根据文件的修改时间和图片的属性获取缩略图
 *
 * @param file
 * @param options
 * @return
 */
private static Bitmap getThumbCache(File file, ImageOptions options) {
    if (!WebPFactory.available()) return null;

    DiskCacheFile cacheFile = null;
    try {
        cacheFile = THUMB_CACHE.getDiskCacheFile(
                file.getAbsolutePath() + "@" + file.lastModified() + options.toString());
        if (cacheFile != null && cacheFile.exists()) {
            BitmapFactory.Options bitmapOps = new BitmapFactory.Options();
            bitmapOps.inJustDecodeBounds = false;
            bitmapOps.inPurgeable = true;
            bitmapOps.inInputShareable = true;
            bitmapOps.inPreferredConfig = Bitmap.Config.ARGB_8888;
            return WebPFactory.decodeFile(cacheFile.getAbsolutePath(), bitmapOps);
        }
    } catch (Throwable ex) {
        LogUtil.w(ex.getMessage(), ex);
    } finally {
        IOUtil.closeQuietly(cacheFile);
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:ImageDecoder.java

示例13: findById

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T findById(Class<T> entityType, Object idValue) throws DbException {
    TableEntity<T> table = TableEntity.get(this, entityType);
    if (!table.tableIsExist()) return null;

    Selector selector = Selector.from(table).where(table.getId().getName(), "=", idValue);

    String sql = selector.limit(1).toString();
    Cursor cursor = execQuery(sql);
    if (cursor != null) {
        try {
            if (cursor.moveToNext()) {
                return CursorUtils.getEntity(table, cursor);
            }
        } catch (Throwable e) {
            throw new DbException(e);
        } finally {
            IOUtil.closeQuietly(cursor);
        }
    }
    return null;
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:24,代码来源:DbManagerImpl.java

示例14: close

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    if (inputStream != null) {
        IOUtil.closeQuietly(inputStream);
        inputStream = null;
    }
    if (connection != null) {
        connection.disconnect();
        //connection = null;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:HttpRequest.java

示例15: deleteFileWithLock

import org.xutils.common.util.IOUtil; //导入方法依赖的package包/类
private boolean deleteFileWithLock(String path) {
    ProcessLock processLock = null;
    try {
        processLock = ProcessLock.tryLock(path, true);
        if (processLock != null && processLock.isValid()) { // lock
            File file = new File(path);
            return IOUtil.deleteFileOrDir(file);
        }
    } finally {
        IOUtil.closeQuietly(processLock);
    }
    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:LruDiskCache.java


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