令牌“/”上的语法错误,此令牌后预期的表达式

时间:2014-02-18 11:00:11

标签: android syntax-error token

为什么我收到此错误? 令牌“/”上的语法错误,此令牌后预期的表达式。

 InputStream in = getResources().openRawResource(R.raw.msgn);
 FileOutputStream out = new FileOutputStream(media/audio/notifications/); // Error is in this line
                    byte[] buff = new byte[1024];
                    int read = 0;

                    try {
                       while ((read = in.read(buff)) > 0) {
                          out.write(buff, 0, read);
                       }
                    } finally {
                         in.close();

                         out.close();

3 个答案:

答案 0 :(得分:5)

他期待一个字符串。你需要双引号

"media/audio/notifications/"

答案 1 :(得分:0)

您必须将media/audio/notifications/放在双引号中并在File构造函数中传递,因为FileOutputStream()期望传递File ...

FileOutputStream out = new FileOutputStream(new File("media/audio/notifications/"));

答案 2 :(得分:0)

你忘了引号这样做:

new FileOutputStream("media/audio/notifications/");