为什么会出现此错误?
标记“/”上的语法错误,该标记后应为表达式。

 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();

最佳答案

您必须将media/audio/notifications/放在双引号中,然后将它们传递到File构造函数中,因为FileOutputStream()期望File可以传入...

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

关于android - token “/”的语法错误,此 token 后需要表达,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21851719/

10-09 05:43