我从“parse.com”中检索到一个“parsefile”,但是我无法找到一个正确的方法来读取“parsefile”,我试图用java的“bufferreader”读取这个parsefile,结果却徒劳无功。
下面是我的代码

 final ParseQuery<ParseObject> query = ParseQuery.getQuery("TestObject");
    query.getInBackground("xxxxxxxxx", new GetCallback<ParseObject>() {
        public void done(ParseObject object, ParseException e) {
            if (e == null) {
                try {
                    ParseFile parseFile=object.getParseFile("file");
                    BufferedReader br = new BufferedReader(new FileReader(String.valueOf(parseFile)));
                    StringBuilder sb = new StringBuilder();
                    String line = br.readLine();
                    while (line != null) {
                        sb.append(line);
                        sb.append("\n");
                        line = br.readLine();

                    }
                    System.out.println("exact values"+sb.toString());
                    br.close(); }
                catch (Exception e1) {
                    e1.printStackTrace();
                }


            } else {
                System.out.println("bye!!");
            }
        }
    });

下面是我的stacktrace:
10-14 00:10:33.178  18300-18300/? W/System.err﹕
java.io.FileNotFoundException:
com.parse.ParseFile@328cdd84: open failed: ENOENT (No such file or
directory)
10-14 00:10:33.178  18300-18300/? W/System.err﹕ at
libcore.io.IoBridge.open(IoBridge.java:409)
10-14 00:10:33.178  18300-18300/? W/System.err﹕ at java.io.FileInputStream.
<init>(FileInputStream.java:78)
10-14 00:10:33.178  18300-18300/? W/System.err﹕ at java.io.FileInputStream.
<init>(FileInputStream.java:105)
10-14 00:10:33.178  18300-18300/? W/System.err﹕ at java.io.FileReader.<init>
(FileReader.java:66)

行filenotfound异常指向:
    BufferedReader br = new BufferedReader(new FileReader(String.valueOf(parseFile)));

任何建议都会很有帮助。
谢谢!

最佳答案

将对象parsefile的字符串传递给filereader,而不是文件。
换行

    BufferedReader br = new BufferedReader(new FileReader(String.valueOf(parseFile)));


BufferedReader br = new BufferedReader(new FileReader(parseFile.getFile()));

关于java - 使用java读取“ParseFile”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33116665/

10-12 03:40