【问题标题】:Blackberry - Adding mp3 files to an sdcard folder from application resourcesBlackberry - 从应用程序资源将 mp3 文件添加到 sdcard 文件夹
【发布时间】:2009-04-15 09:43:38
【问题描述】:

我的黑莓应用程序捆绑了一些 mp3 文件。我想通过程序将这些文件从应用程序添加到sdcard中的文件夹或手机内存中的文件夹中。

我该怎么做?有可能吗?

谢谢。

【问题讨论】:

    标签: blackberry file-io java-me resources jsr75


    【解决方案1】:

    可以,将资源作为流打开:

    String fileName = "/myPath/myFile.mp3";
    InputStream inputStream = getClass().getResourceAsStream(fileName);
    

    然后读取流并将其写入文件:

    String locator = "file:///SDCard"+fileName;
    FileConnection saveFile = (FileConnection)Connector.open(locator);
    saveFile.create();
    OutputStream outputStream = saveFile.openOutputStream();
    

    我相信你可以遍历 inputStream 以将其复制到 outputStream,然后关闭。

    【讨论】:

      猜你喜欢
      • 2013-05-28
      • 2016-01-28
      • 2013-02-03
      • 1970-01-01
      • 1970-01-01
      • 2021-04-29
      • 1970-01-01
      • 2020-01-31
      • 2017-12-05
      相关资源
      最近更新 更多