JDK 10 RFR of 8182710: File.listRoots() always returns the root of CD drive
Tagir Valeev
amaembo at gmail.com
Thu Jun 29 05:50:20 UTC 2017
Looks good as well.
With best regards,
Tagir Valeev.
On Wed, Jun 28, 2017 at 8:49 PM, Brian Burkhalter <
brian.burkhalter at oracle.com> wrote:
> 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