Here you can find the source of toFiles(@Nonnull Process p, @Nonnull Charset charset)
@Nonnull public static File[] toFiles(@Nonnull Process p, @Nonnull Charset charset) throws IOException
//package com.java2s; /*/*from w w w .java 2 s. c om*/ * Copyright 2015 National Bank of Belgium * * Licensed under the EUPL, Version 1.1 or - as soon they will be approved * by the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * * http://ec.europa.eu/idabc/eupl * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. */ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; public class Main { @Nonnull public static File[] toFiles(@Nonnull Process p, @Nonnull Charset charset) throws IOException { List<File> result = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), charset))) { // we need the process to end, else we'll get an illegal Thread State Exception String line; while ((line = reader.readLine()) != null) { result.add(new File(line)); } try { p.waitFor(); } catch (InterruptedException ex) { // do nothing? } } return result.toArray(new File[result.size()]); } }