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


Java IOUtil类代码示例

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


IOUtil类属于org.xutils.common.util包,在下文中一共展示了IOUtil类的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: prepare

import org.xutils.common.util.IOUtil; //导入依赖的package包/类
@Override
public Drawable prepare(File rawData) {
    if (!validView4Callback(true)) return null;

    try {
        Drawable result = null;
        if (prepareCallback != null) {
            result = prepareCallback.prepare(rawData);
        }
        if (result == null) {
            result = ImageDecoder.decodeFileWithLock(rawData, options, this);
        }
        if (result != null) {
            if (result instanceof ReusableDrawable) {
                ((ReusableDrawable) result).setMemCacheKey(key);
                MEM_CACHE.put(key, result);
            }
        }
        return result;
    } catch (IOException ex) {
        IOUtil.deleteFileOrDir(rawData);
        LogUtil.w(ex.getMessage(), ex);
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ImageLoader.java

示例13: 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

示例14: 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

示例15: 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


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