JDK 10 RFR of 8182710: File.listRoots() always returns the root of CD drive
Brian Burkhalter
brian.burkhalter at oracle.com
Wed Jun 28 17:49:03 UTC 2017
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