public static String readAsString(URL url) { try { return IOHelpers.readFully(url); } catch (IOException e) { throw new RuntimeException(e); } }
public static String readFully(File file) throws IOException { if (!file.isFile()) { return null; } InputStream in = new FileInputStream(file); return readFully(in); }
public static String readFully(InputStream in) throws IOException { Reader r = new BufferedReader(new InputStreamReader(in)); return readFully(r); }
private void runProcess(String commands, boolean verbose) throws IOException { ProcessBuilder builder = new ProcessBuilder("bash", "-c", commands); Process process = builder.start(); String out = IOHelpers.readFully(process.getInputStream()); String err = IOHelpers.readFully(process.getErrorStream()); if (verbose) { listener.getLogger().println("command: " + commands + " out: " + out); listener.getLogger().println("command: " + commands + " err: " + err); } }
@GET @Produces(MediaType.TEXT_HTML) public String index() throws IOException { URL resource = getClass().getResource("index.html"); if (resource != null) { InputStream in = resource.openStream(); if (in != null) { return IOHelpers.readFully(in); } } return null; }
@GET @Produces(MediaType.TEXT_HTML) public String index() throws IOException { URL resource = getClass().getResource("index.html"); if (resource != null) { InputStream in = resource.openStream(); if (in != null) { return IOHelpers.readFully(in); } } return null; }
private void runProcess(String commands, boolean verbose) throws IOException { ProcessBuilder builder = new ProcessBuilder("bash", "-c", commands); Process process = builder.start(); String out = IOHelpers.readFully(process.getInputStream()); String err = IOHelpers.readFully(process.getErrorStream()); if (verbose) { listener.getLogger().println("command: " + commands + " out: " + out); listener.getLogger().println("command: " + commands + " err: " + err); } }
@GET @Produces(MediaType.TEXT_HTML) public String index() throws IOException { URL resource = getClass().getResource("index.html"); if (resource != null) { InputStream in = resource.openStream(); if (in != null) { return IOHelpers.readFully(in); } } return null; }
@GET @Produces(MediaType.TEXT_HTML) public String index() throws IOException { URL resource = getClass().getResource("index.html"); if (resource != null) { InputStream in = resource.openStream(); if (in != null) { return IOHelpers.readFully(in); } } return null; }
@GET @Produces(MediaType.TEXT_HTML) public String index() throws IOException { URL resource = getClass().getResource("index.html"); if (resource != null) { InputStream in = resource.openStream(); if (in != null) { return IOHelpers.readFully(in); } } return null; }
protected static String loadFile(File file) { String output = null; if (Files.isFile(file)) { try { output = IOHelpers.readFully(file); } catch (IOException e) { LOG.error("Failed to load " + file + ". " + e, e); } } return output; }
protected static String loadFile(File file) { String output = null; if (Files.isFile(file)) { try { output = IOHelpers.readFully(file); } catch (IOException e) { LOG.error("Failed to load " + file + ". " + e, e); } } return output; }
@Override public Exception fromResponse(Response response) { try { Object entity = response.getEntity(); String message = "No message"; if (entity instanceof InputStream) { InputStream inputStream = (InputStream) entity; message = IOHelpers.readFully(inputStream); } else if (entity != null) { message = entity.toString(); } message = "HTTP " + response.getStatus() + " " + message; return new WebApplicationException(message, response); } catch (Exception ex) { return new Exception("Could not deserialize server side exception: " + ex.getMessage()); } }
private static String getFlowContent(String flow, UIContext context) { File dir = getJenkinsWorkflowFolder(context); if (dir != null) { File file = new File(dir, flow); if (file.isFile() && file.exists()) { try { return IOHelpers.readFully(file); } catch (IOException e) { LOG.warn("Failed to load local pipeline " + file + ". " + e, e); } } } return null; }
if (in != null) { try { version = IOHelpers.readFully(in).trim(); } catch (IOException e) {
if (in != null) { try { version = IOHelpers.readFully(in).trim(); } catch (IOException e) {
String text = IOHelpers.readFully(bomFile); Document doc = archetypeUtils.parseXml(new InputSource(new StringReader(text))); Element root = doc.getDocumentElement();
protected void copyFile(File src, File dest, Replacement replaceFn, boolean isSource) throws IOException { if (replaceFn != null && isSource) { String original = IOHelpers.readFully(src); String escapedContent = original; if (original.contains("${")) { String replaced = escapedContent.replaceAll(Pattern.quote("${"), "\\${D}{"); // add Velocity expression at the beginning of the result file. // Velocity is used by mvn archetype:generate escapedContent = "#set( $D = '$' )\n" + replaced; } if (original.contains("##")) { String replaced = escapedContent.replaceAll(Pattern.quote("##"), "\\${H}"); // add Velocity expression at the beginning of the result file. // Velocity is used by mvn archetype:generate escapedContent = "#set( $H = '##' )\n" + replaced; } // do additional replacement String text = replaceFn.replace(escapedContent); IOHelpers.writeFully(dest, text); } else { if (LOG.isDebugEnabled()) { LOG.warn("Not a source dir as the extension is {}", Files.getExtension(src.getName())); } Files.copy(src, dest); } }
String text = IOHelpers.readFully(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); String[] lines = text.split("\n"); String regex = command.getRegex();
String applicationPropertiesText = IOHelpers.readFully(applicationPropertiesFile); if (Strings.isNotBlank(applicationPropertiesText)) { data.put(DataKeys.Connector.APPLICATION_PROPERTIES, applicationPropertiesText);