Java tutorial
/*- * #%L * che-starter * %% * Copyright (C) 2017 Red Hat, Inc. * %% * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * #L% */ package io.fabric8.che.starter.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Scanner; import java.util.stream.Collectors; import org.springframework.stereotype.Component; @Component public final class Reader { public String read(InputStream input) throws IOException { try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) { return buffer.lines().collect(Collectors.joining("\n")); } } public String read(URL url) throws IOException { try (Scanner skanner = new Scanner(url.openStream(), "UTF-8")) { return skanner.useDelimiter("\\A").next(); } } }