Write Stream<String> to a file?

Mike Duigou mike.duigou at oracle.com
Tue Nov 19 17:04:03 PST 2013


There are now constants for the standard charsets. 

StandardCharsets.UTF_8

Which can be statically imported for even more concise referencing.

Mike

On Nov 19 2013, at 15:35 , Sam Pullara <spullara at gmail.com> wrote:

> Hmmm. Maybe something like:
> 
>    Charset cs = Charset.forName("UTF-8");
>    Stream<String> oldfile = Files.lines(Paths.get(args[0]), cs);
>    Files.write(Paths.get(args[1]), oldfile::iterator, cs);
> 
> Sam
> 
> On Nov 19, 2013, at 3:19 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:
> 
>> We have convenience methods to read lines from a file:
>>   Stream<String> Files.lines()
>> 
>> What's Java's idiomatic way to write a Stream<String> to a file?
>> 
>> Zhong Yu
>> 
> 
> 



More information about the lambda-dev mailing list