小编bar*_*ala的帖子

如何在android中获取正确的路径文件

我的代码如下:

Scanner sc = null;
try {
    sc = new Scanner(new File("assets/mainmenu/readSourceFile.txt"));
} catch (FileNotFoundException e1) {
    // TODO Auto-generated catch block
    System.out.println(e1.toString());
    e1.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

然后,logcat显示异常 java.io.FileNotFoundException

我怎样才能找到我的档案?我试过了

sc = new Scanner(new File("mainmenu/readSourceFile.txt"));

然而,它仍然是扔 FilenotFoundException

我的文件位于文件夹assets/mainmenu/readSourceFile.txt中

我试试这个::

private InputStream is;
try {
        is = this.getResources().getAssets().open("mainmenu/readSourceFile.txt");
    } catch (IOException e) {
        e.toString();
    }
Run Code Online (Sandbox Code Playgroud)

我使用getAssets来访问android中的资产文件.但是,如果我使用,我怎么能想读取文本文件InputStream

java android

7
推荐指数
1
解决办法
1832
查看次数

如何在标签中设置文字强?

我想知道我是否可以<strong>在javascript中设置文本或初始文本.

<!DOCTYPE html>
<html>
<body>
<script>
$(document).ready(function(){
// what should I do here?
}
</script>
<strong>Strong text</strong>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

非常感谢.

html javascript jquery

5
推荐指数
2
解决办法
2万
查看次数

关于c ++中的内存和删除对象

我将举一些例子并解释一下.首先,我声明一些对象

CString* param = new CString[100]

当我宣布这个时,我的记忆会增加一点,因为它是一些实现的字符串.然后我将这个对象存储在一些CString列表中

List<CString> myList = new List<CString>; // new list of CString

myList.add(param);
Run Code Online (Sandbox Code Playgroud)

这是我的问题:我想知道,当我删除myList时,我的参数不会被删除,对吧?参数中的记忆仍然存在.

我误解了吗?

c++

1
推荐指数
1
解决办法
145
查看次数

标签 统计

android ×1

c++ ×1

html ×1

java ×1

javascript ×1

jquery ×1