hudson.util.IOUtils.toString()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中hudson.util.IOUtils.toString()方法的一些代码示例,展示了IOUtils.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.toString()方法的具体详情如下:
包路径:hudson.util.IOUtils
类名称:IOUtils
方法名:toString

IOUtils.toString介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/artifactory-plugin

/**
 * Converts the http entity to string. If entity is null, returns empty string.
 * @param entity
 * @return
 * @throws IOException
 */
public static String entityToString(HttpEntity entity) throws IOException {
  if (entity != null) {
    InputStream is = entity.getContent();
    return IOUtils.toString(is, "UTF-8");
  }
  return "";
}

代码示例来源:origin: jenkinsci/shiningpanda-plugin

/**
 * Get the BUILDOUT bootstrap module content.
 * 
 * @return The BUILDOUT bootstrap module content
 * @throws IOException
 */
public String getBootstrapPyContent() throws IOException {
return IOUtils.toString(getClass().getResourceAsStream(BOOTSTRAP));
}

代码示例来源:origin: jenkinsci/shiningpanda-plugin

/**
 * Get the VIRTUALENV module content.
 * 
 * @return The VIRTUALENV module content
 * @throws IOException
 */
public String getVirtualenvPyContent() throws IOException {
return IOUtils.toString(getClass().getResourceAsStream(VIRTUALENV));
}

代码示例来源:origin: Argelbargel/gitlab-branch-source-plugin

@SuppressWarnings("deprecation")
  private String getRequestBody(HttpServletRequest request) throws IOException {
    String charset = request.getCharacterEncoding() == null ? CHARSET_UTF_8 : request.getCharacterEncoding();
    String requestBody = IOUtils.toString(request.getInputStream(), charset);
    if (StringUtils.isBlank(requestBody)) {
      throw new IllegalArgumentException("request-body is empty");
    }

    return requestBody;
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Reads this file into a string, by using the current system encoding.
 */
public String readToString() throws IOException {
  InputStream in = read();
  try {
    return IOUtils.toString(in);
  } finally {
    in.close();
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Reads this file into a string, by using the current system encoding.
 */
public String readToString() throws IOException {
  InputStream in = read();
  try {
    return IOUtils.toString(in);
  } finally {
    in.close();
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Reads this file into a string, by using the current system encoding.
 */
public String readToString() throws IOException {
  InputStream in = read();
  try {
    return IOUtils.toString(in);
  } finally {
    in.close();
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Reads this file into a string, by using the current system encoding.
 */
public String readToString() throws IOException {
  InputStream in = read();
  try {
    return IOUtils.toString(in);
  } finally {
    in.close();
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

private int readSmbFile(SmbFile f) throws IOException {
  InputStream in=null;
  try {
    in = f.getInputStream();
    return Integer.parseInt(IOUtils.toString(in));
  } finally {
    IOUtils.closeQuietly(in);
  }
}

代码示例来源:origin: hudson/hudson-2.x

private int readSmbFile(SmbFile f) throws IOException {
  InputStream in=null;
  try {
    in = f.getInputStream();
    return Integer.parseInt(IOUtils.toString(in));
  } finally {
    IOUtils.closeQuietly(in);
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * This is where the browser sends us the data. 
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException {
  long dataTimestamp = System.currentTimeMillis();
  TextFile df = getDataFile();
  df.write(IOUtils.toString(req.getInputStream(),"UTF-8"));
  df.file.setLastModified(dataTimestamp);
  due = dataTimestamp+getInterval();
  LOGGER.info("Obtained the updated data file for "+id);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * This is where the browser sends us the data. 
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException {
  long dataTimestamp = System.currentTimeMillis();
  TextFile df = getDataFile();
  df.write(IOUtils.toString(req.getInputStream(),"UTF-8"));
  df.file.setLastModified(dataTimestamp);
  due = dataTimestamp+getInterval();
  LOGGER.info("Obtained the updated data file for "+id);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * This is where the browser sends us the data.
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException {
  long dataTimestamp = System.currentTimeMillis();
  TextFile df = getDataFile();
  df.write(IOUtils.toString(req.getInputStream(), "UTF-8"));
  df.file.setLastModified(dataTimestamp);
  due = dataTimestamp + getInterval();
  LOGGER.info("Obtained the updated data file for " + id);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * This is where the browser sends us the data. 
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException {
  long dataTimestamp = System.currentTimeMillis();
  TextFile df = getDataFile();
  df.write(IOUtils.toString(req.getInputStream(),"UTF-8"));
  df.file.setLastModified(dataTimestamp);
  due = dataTimestamp+getInterval();
  LOGGER.info("Obtained the updated data file for "+id);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: com.cisco.step.jenkins.plugins/jenkow-plugin

public void ensureWorkflowDefinition(String wfName) throws Exception{
  // due to lazy loading of engine:
  // the engine startup would try to deploy the file we're about to create, leading to a double deploy
  JenkowEngine.getEngine();
  String relName = mkWfPath(wfName);
  File wff = new File(getRepositoryDir(),relName);
  if (!wff.exists()){
    LOGGER.info("generating workflow definition "+wff);
    Map<String,String> vars = new HashMap<String,String>();
    vars.put("WORKFLOW_ID",WfUtil.mkWorkflowId(wfName));
    vars.put("WORKFLOW_NAME",wfName);
    String wfd = IOUtils.toString(getClass().getResourceAsStream("/templates/new.bpmn"));
    wfd = Util.replaceMacro(wfd,vars);
    FileUtils.writeStringToFile(wff,wfd);
    
    Repository r = openRepository();
    addAndCommit(r,relName,"added generated workflow definition "+wfName);
    r.close();
  }
  WfUtil.deployToEngine(wff);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * This is the endpoint that receives the update center data file from the browser.
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException {
  dataTimestamp = System.currentTimeMillis();
  String json = IOUtils.toString(req.getInputStream(),"UTF-8");
  JSONObject o = JSONObject.fromObject(json);
  int v = o.getInt("updateCenterVersion");
  if(v !=1) {
    LOGGER.warning("Unrecognized update center version: "+v);
    return;
  }
  if (signatureCheck)
    verifySignature(o);
  LOGGER.info("Obtained the latest update center data file for UpdateSource "+ id);
  getDataFile().write(json);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * This is the endpoint that receives the update center data file from the browser.
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException {
  dataTimestamp = System.currentTimeMillis();
  String json = IOUtils.toString(req.getInputStream(),"UTF-8");
  JSONObject o = JSONObject.fromObject(json);
  int v = o.getInt("updateCenterVersion");
  if(v !=1) {
    LOGGER.warning("Unrecognized update center version: "+v);
    return;
  }
  if (signatureCheck)
    verifySignature(o);
  LOGGER.info("Obtained the latest update center data file for UpdateSource "+ id);
  getDataFile().write(json);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * This is the endpoint that receives the update center data file from the browser.
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException {
  dataTimestamp = System.currentTimeMillis();
  String json = IOUtils.toString(req.getInputStream(),"UTF-8");
  JSONObject o = JSONObject.fromObject(json);
  int v = o.getInt("updateCenterVersion");
  if(v !=1) {
    LOGGER.warning("Unrecognized update center version: "+v);
    return;
  }
  if (signatureCheck)
    verifySignature(o);
  LOGGER.info("Obtained the latest update center data file for UpdateSource "+ id);
  getDataFile().write(json);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * This is the endpoint that receives the update center data file from the
 * browser.
 */
public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException {
  dataTimestamp = System.currentTimeMillis();
  String json = IOUtils.toString(req.getInputStream(), "UTF-8");
  JSONObject o = JSONObject.fromObject(json);
  int v = o.getInt("updateCenterVersion");
  if (v != 1) {
    LOGGER.warning("Unrecognized update center version: " + v);
    return;
  }
  if (signatureCheck) {
    verifySignature(o);
  }
  LOGGER.info("Obtained the latest update center data file for UpdateSource " + id);
  getDataFile().write(json);
  rsp.setContentType("text/plain");  // So browser won't try to parse response
}

代码示例来源:origin: jenkinsci/gerrit-trigger-plugin

/**
   * Retrieves the Gerrit command.
   *
   * @param request  the request
   * @param response the response
   * @throws IOException if so.
   */
  public void doDynamic(StaplerRequest request, StaplerResponse response) throws IOException {
    lastPath = request.getRestOfPath();
    lastContent = IOUtils.toString(request.getReader());
    response.setContentType("application/json");
    PrintWriter writer = response.getWriter();
    writer.write(new JSONObject(true).toString());
    writer.flush();
  }
}

相关文章