zoukankan      html  css  js  c++  java
  • Android 获取assets的绝对路径

    第一种方法:
           String path = "file:///android_asset/文件名";

    第二种方法
        InputStream abpath = getClass().getResourceAsStream("/assets/文件名");


    若要想要转换成String类型

    String path = new String(InputStreamToByte(abpath ));


    private byte[] InputStreamToByte(InputStream is) throws IOException {
            ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
            int ch;
            while ((ch = is.read()) != -1) {
                bytestream.write(ch);
            }
            byte imgdata[] = bytestream.toByteArray();
            bytestream.close();
            return imgdata;
    }

  • 相关阅读:
    逗号操作符使用小技巧
    字符解码?
    画图 wx.Window pen
    进程和线程
    内存管理
    简单的文本编辑器
    迭代器 Iterator
    文件操作
    ebay api学习
    一,wxpython入门
  • 原文地址:https://www.cnblogs.com/androidsj/p/3622103.html
Copyright © 2011-2022 走看看