Skip to content Skip to sidebar Skip to footer

Printwriter Truncates String When Writing To File, Why?

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

Solution 1:

You need to close the PrintWriter using PrintWriter#close() method

Add

out.close();

Solution 2:

It doesn't. You failed to close the file.

Post a Comment for "Printwriter Truncates String When Writing To File, Why?"