怎么做文件输入/输出

时间:2014-03-30 03:52:36

标签: java android

我是java的初学者。我正在为android做数据库然后我面对这个程序。但我无法理解这个程序。请帮助我任何人。如何逐步实施。

public void copyDatabase() {

        try {
            InputStream dbInputStream = context.getAssets().open(DB_NAME);
            String path = DB_PATH + DB_NAME;
            OutputStream dbOutputStream = new FileOutputStream(path);
            byte[] buffer = new byte[4096];
            int readCount = 0;
            while ((readCount = dbInputStream.read(buffer)) > 0) {
                dbOutputStream.write(buffer, 0, readCount);

            }
            dbInputStream.close();
            dbOutputStream.close();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

0 个答案:

没有答案