I'm writing to a file using PrintWriter like this:
Gson g = new Gson();
Article article = g.fromJson(reader, Article.class);
String json = g.toJson(article);
PrintWriter out = new PrintWriter(new FileWriter(cacheFile.getAbsolutePath()));
out.print(json);
However, the string in json is truncated when I see it in the file. What could be the reason for that?
It doesn't. You failed to close the file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.