JDK8至JDK 11 常用API更新

1) Optional
新增:

stream()
ifPresentOrElse​(Consumer action, Runnable emptyAction)
or​(Supplier> supplier)

版本: 9

orElseThrow()

版本: 10

isEmpty()

版本: 11

2) CompletableFuture
新增:

completeOnTimeout​(T value, long timeout, TimeUnit unit)
newIncompleteFuture()
defaultExecutor()
copy()
minimalCompletionStage()
completeAsync​(Supplier 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

3) Stream
新增:

takeWhile​(Predicate predicate)
dropWhile​(Predicate predicate)
ofNullable​(T t)
iterate​(T seed, Predicate hasNext, UnaryOperator next)

版本: 9

4) Map
新增:

of() 系列方法
entry​(K k, V v)

版本: 9

copyOf​(Map map)

版本: 10

5) List
新增:

of() 系列方法

版本: 9

copyOf​(Collection coll)

版本: 10

6) Set
新增:

of() 系列方法

版本: 9

copyOf​(Collection coll)

版本: 10

7) LocalDate
新增:

datesUntil​(LocalDate endExclusive)
datesUntil​(LocalDate endExclusive, Period step)
toEpochSecond​(LocalTime time, ZoneOffset offset)

版本: 9

8) Locale
新增:

getISOCountries​(Locale.IsoCountryCode type)

版本: 9

9) String
新增:

strip()
stripLeading()
stripTrailing()
isBlank()
lines()
repeat​(int count)

版本: 11

chars()
codePoints()

版本: 9

10) HttpClient
新增类
版本: 11

11) 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

12) OutputStream
新增:

nullInputStream()

版本: 11

13) ByteArrayOutputStream
新增:

writeBytes​(byte[] b)

版本: 11

toString​(Charset charset)

版本: 10

14) Selector
新增:

select​(Consumer action, long timeout) throws IOException
select​(Consumer action) throws IOException
selectNow​(Consumer action) throws IOException

版本: 11

15) Objects
新增:

requireNonNullElse​(T obj, T defaultObj)
requireNonNullElseGet​(T obj, Supplier supplier)
checkIndex​(int index, int length)
checkFromToIndex​(int fromIndex, int toIndex, int length)
checkFromIndexSize​(int fromIndex, int size, int length)

版本: 9

16) Path
新增:

of​(String first, String... more)
of​(URI uri)

版本: 11

17) 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

18) Socket
新增:

setOption​(SocketOption name, T value) throws IOException
getOption​(SocketOption name) throws IOException
supportedOptions()

版本: 9

19) HttpURLConnection
新增:

setAuthenticator​(Authenticator auth)

版本: 9

20) URLClassLoader
新增:

URLClassLoader​(String name, URL[] urls, ClassLoader parent)
URLClassLoader​(String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory)

版本: 9

你可能感兴趣的:(jdkjdk8jdk11)