Quantcast
Channel: How do I create a Java string from the contents of a file? - Stack Overflow
Viewing all articles
Browse latest Browse all 36

Answer by leventov for How do I create a Java string from the contents of a file?

$
0
0

Since JDK 11:

String file = ...Path path = Paths.get(file);String content = Files.readString(path);// Or readString(path, someCharset), if you need a Charset different from UTF-8

Viewing all articles
Browse latest Browse all 36

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>