JDK 10 RFR of 8182710: File.listRoots() always returns the root of CD drive

Langer, Christoph christoph.langer at sap.com
Thu Jun 29 07:25:55 UTC 2017


Looks good.

Best regards
Christoph

> -----Original Message-----
> From: core-libs-dev [mailto:core-libs-dev-bounces at openjdk.java.net] On
> Behalf Of Brian Burkhalter
> Sent: Mittwoch, 28. Juni 2017 19:49
> To: core-libs-dev <core-libs-dev at openjdk.java.net>
> Subject: Re: JDK 10 RFR of 8182710: File.listRoots() always returns the root of
> CD drive
> 
> I rather like that. How about this (without "ds")?
> 
>     public File[] listRoots() {
>         return BitSet
>             .valueOf(new long[] {listRoots0()})
>             .stream()
>             .mapToObj(i -> new File((char)('A' + i) + ":" + slash))
>             .filter(f -> access(f.getPath()) && f.exists())
>             .toArray(File[]::new);
>     }
> 
> Thanks,
> 
> Brian
> 
> On Jun 27, 2017, at 10:54 PM, Tagir Valeev <amaembo at gmail.com> wrote:
> 
> > Just an alternative which looks more readable to me (no explicit bit
> twiddling):
> > -        int ds = listRoots0();
> > -        return IntStream
> > -            .range(0, 26)
> > -            .filter(i -> ((ds >> i) & 1) != 0)
> > +       long[] ds = {listRoots0()};
> > +       return BitSet
> > +            .valueOf(ds)
> > +            .stream()
> >
> > Probably a matter of taste though.



More information about the core-libs-dev mailing list