@@ -0,0 +1,1316 @@
+/*%0A * Copyright (C) 2014-present  The   openSourcLibrary-2015  Authors%0A *%0A * https://github.com/sdcuike%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A */%0Apackage com.doctor.java8;%0A%0Aimport java.util.Arrays;%0Aimport java.util.stream.Stream;%0A%0A/**%0A * Convert Stream to Array in Java 8%0A * %0A * @author doctor%0A * %0A * @see http://www.programcreek.com/2014/01/convert-stream-to-array-in-java-8/%0A *%0A * @time 2015%E5%B9%B48%E6%9C%885%E6%97%A5 %E4%B8%8A%E5%8D%8810:38:41%0A *%0A */%0Apublic class ConvertStreamToArrayInJava8 %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09String%5B%5D strings = %7B%22hello%22,%22doctor%22,%22who are you%22%7D;%0A%09%09String%5B%5D array = Stream.of(strings).toArray(String%5B%5D::new);%0A%09%09System.out.println(Arrays.toString(array));%0A%09%09%0A%09%09String%5B%5D array2 = Stream.of(strings).toArray(size -%3E new String%5Bsize%5D);%0A%09%09System.out.println(Arrays.toString(array2));%0A%0A%09%7D%0A%0A%7D%0A

Convert Stream to Array in Java 8