I have a one question. How can I get all text file content to String format? Please show me that code. Thank you. P.S Search didin't help. Sorry for my bad English.
Asked
Active
Viewed 80 times
-3
-
*Search didin't help* ?. Where did you search? – TheLostMind Aug 06 '14 at 13:16
-
Also, _show me that code_: Well, no, that's not how StackOverflow works. Post your attempts, and tell us what doesn't work, what the code does and what it was supposed to do instead. Also, post the stacktrace if some exception is thrown. We help, we don't write code for you. – BackSlash Aug 06 '14 at 13:18
-
1Obvious duplicate, very poor question (code request without effort shown), and yet someone upvotes? I don't understand... – kviiri Aug 06 '14 at 13:20
1 Answers
0
public static String deserializeString(File file)
throws IOException {
int len;
char[] chr = new char[4096];
final StringBuffer buffer = new StringBuffer();
final FileReader reader = new FileReader(file);
try {
while ((len = reader.read(chr)) > 0) {
buffer.append(chr, 0, len);
}
} finally {
reader.close();
}
return buffer.toString();
}

Wolfish
- 960
- 2
- 8
- 34