美文网首页
JDK8至JDK 11 常用API更新

JDK8至JDK 11 常用API更新

作者: xiaofanku | 来源:发表于2021-03-18 17:25 被阅读0次
  1. Optional
    新增:
stream()
ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction)
or(Supplier<? extends Optional<? extends T>> supplier)

版本: 9

orElseThrow()

版本: 10

isEmpty()

版本: 11

  1. CompletableFuture
    新增:
completeOnTimeout(T value, long timeout, TimeUnit unit)
newIncompleteFuture()
defaultExecutor()
copy()
minimalCompletionStage()
completeAsync(Supplier<? extends T> supplier, Executor executor)
orTimeout(long timeout, TimeUnit unit)
delayedExecutor(long delay, TimeUnit unit, Executor executor)
delayedExecutor(long delay, TimeUnit unit)
completedStage(U value)
failedFuture(Throwable ex)
failedStage(Throwable ex)

版本: 9

  1. Stream
    新增:
takeWhile(Predicate<? super T> predicate)
dropWhile(Predicate<? super T> predicate)
ofNullable(T t)
iterate(T seed, Predicate<? super T> hasNext, UnaryOperator<T> next)

版本: 9

  1. Map
    新增:
of() 系列方法
entry(K k, V v)

版本: 9

copyOf(Map<? extends K,? extends V> map)

版本: 10

  1. List
    新增:
of() 系列方法

版本: 9

copyOf(Collection<? extends E> coll)

版本: 10

  1. Set
    新增:
of() 系列方法

版本: 9

copyOf(Collection<? extends E> coll)

版本: 10

  1. LocalDate
    新增:
datesUntil(LocalDate endExclusive)
datesUntil(LocalDate endExclusive, Period step)
toEpochSecond(LocalTime time, ZoneOffset offset)

版本: 9

  1. Locale
    新增:
getISOCountries(Locale.IsoCountryCode type)

版本: 9

  1. String
    新增:
strip()
stripLeading()
stripTrailing()
isBlank()
lines()
repeat(int count)

版本: 11

chars()
codePoints()

版本: 9

  1. HttpClient
    新增类
    版本: 11

  2. InputStream
    新增:

nullInputStream()
readNBytes(int len) throws IOException

版本: 11

readAllBytes() throws IOException
readNBytes(byte[] b, int off, int len) throws IOException
transferTo(OutputStream out) throws IOException

版本: 9

  1. OutputStream
    新增:
nullOutputStream()

版本: 11

  1. ByteArrayOutputStream
    新增:
writeBytes(byte[] b)

版本: 11

toString(Charset charset)

版本: 10

  1. Selector
    新增:
select(Consumer<SelectionKey> action, long timeout) throws IOException
select(Consumer<SelectionKey> action) throws IOException
selectNow(Consumer<SelectionKey> action) throws IOException

版本: 11

  1. Objects
    新增:
requireNonNullElse(T obj, T defaultObj)
requireNonNullElseGet(T obj, Supplier<? extends T> supplier)
checkIndex(int index, int length)
checkFromToIndex(int fromIndex, int toIndex, int length)
checkFromIndexSize(int fromIndex, int size, int length)

版本: 9

  1. Path
    新增:
of(String first, String... more)
of(URI uri)

版本: 11

  1. Files
    新增:
readString(Path path) throws IOException
readString(Path path, Charset cs) throws IOException
writeString(Path path, CharSequence csq, OpenOption... options) throws IOException
writeString(Path path, CharSequence csq, Charset cs, OpenOption... options) throws IOException

版本: 11

  1. Socket
    新增:
setOption(SocketOption<T> name, T value) throws IOException
getOption(SocketOption<T> name) throws IOException
supportedOptions()

版本: 9

  1. HttpURLConnection
    新增:
setAuthenticator(Authenticator auth)

版本: 9

  1. URLClassLoader
    新增:
URLClassLoader(String name, URL[] urls, ClassLoader parent)
URLClassLoader(String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory)

版本: 9

相关文章

网友评论

      本文标题:JDK8至JDK 11 常用API更新

      本文链接:https://www.haomeiwen.com/subject/xjdpcltx.html