com.sap.psr.vulas.shared.util.FileUtil.writeToFile()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(157)

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

FileUtil.writeToFile介绍

[英]Writes a String to the given File.
[中]将字符串写入给定文件。

代码示例

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Writes a {@link String} to the given {@link File}.
 */
public static final void writeToFile(File _f, String _content) throws IOException {
  FileUtil.writeToFile(_f, _content.getBytes(FileUtil.getCharset()));
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

public boolean write(T _object, Path _path) {
    boolean success = false;
    if(_object!=null && _path!=null) {
      // Serialize
      final String json = JacksonUtil.asJsonString(_object);
      // Write
      try {
        FileUtil.writeToFile(_path.toFile(), json);
        success = true;
      } catch (IOException e) {
        log.error("Error writing to file [" + _path + "]: " + e.getMessage(), e);
      }
    }
    return success;
  }    
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Writes the given content to a file that is in
 * the temporary directory returned by {@link VulasConfiguration#getTmpDir()}.
 * @return the path of the file
 */
public static final Path writeToTmpFile(String _filename, String _suffix, String _content) throws IOException {
  final Path dir = VulasConfiguration.getGlobal().getTmpDir();
  final String prefix = (_filename!=null ? _filename + "-" : "vulas-tmp-");
  final File f = File.createTempFile(prefix, "." + _suffix, dir.toFile());
  FileUtil.writeToFile(f, _content.getBytes(FileUtil.getCharset()));
  return f.toPath();
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

@Override
public void savePayloadToDisk()  throws IOException {
  if(this.hasPayload()) {
    final File json_file = this.getPayloadPath().toFile();
    // TODO: Use relative paths for the payload
    this.payloadFile = this.getPayloadFilename();
    FileUtil.writeToFile(json_file, this.payload);
    BasicHttpRequest.log.info("Request body (JSON) written to [" + json_file + "]");
  }
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Reads the bytecode of the given {@link CtClass} and writes it to a temporary file.
 * @param _cid
 * @param _class
 * @return the temporary file to which the byte code has been written
 * @throws IOException
 */
private Path writeBytesToTmpFile(JavaClassId _cid, CtClass _class) throws IOException {
  final Path class_file = Files.createTempFile(VulasConfiguration.getGlobal().getTmpDir(), _cid.getQualifiedName(), ".class", new FileAttribute[] {});
  FileUtil.writeToFile(class_file.toFile(), this.readBytes(_class));
  return class_file;
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

p = Paths.get(VulasConfiguration.getGlobal().getTmpDir().toString(), this.javaId.getJavaPackageId().getQualifiedName().replace('.','/'), this.javaId.getName().replace('<', '_').replace('>','_') + ".class");
  FileUtil.createDirectory(p.getParent());
  FileUtil.writeToFile(p.toFile(), this.bytes);
} catch(IOException e) {
  ClassVisitor.getLog().warn("Cannot write bytecode of " + this.javaId+ " to file [" + p + "]: " + e.getMessage());

代码示例来源:origin: SAP/vulnerability-assessment-tool

p = Paths.get(VulasConfiguration.getGlobal().getTmpDir().toString(), _jid.getJavaPackageId().getQualifiedName().replace('.','/'), _jid.getDefinitionContext().getName() + "." + _jid.getName().replace('<', '_').replace('>','_') + ".java");
FileUtil.createDirectory(p.getParent());
FileUtil.writeToFile(p.toFile(), ClassVisitor.prettyPrint(source_code.toString()));

代码示例来源:origin: SAP/vulnerability-assessment-tool

FileUtil.writeToFile(astV, cpr.getVulnAst());
   FileUtil.writeToFile(astF, cpr.getFixedAst());
int random = ran.nextInt();
 String path = PEConfiguration.getBaseFolder().toString() + File.separator  +"asts"+File.separator  +bugId+"_testedAst_"+random+".txt";
FileUtil.writeToFile(new File(path), cpr.getLidResult().getAst_lid());
 sb.append(File.separator+"asts"+ File.separator  +bugId+"_testedAst_"+random+".txt");

代码示例来源:origin: SAP/vulnerability-assessment-tool

BasicHttpRequest.log.error(e.getMessage());
try {
  FileUtil.writeToFile(new File(VulasConfiguration.getGlobal().getTmpDir().toFile(), this.getFilename() + ".html"), e.getHttpResponseBody());
} catch (IOException e1) {
  BasicHttpRequest.log.error("Error saving HTTP error message: " + e1.getMessage(), e1);

代码示例来源:origin: SAP/vulnerability-assessment-tool

final File json_file = Paths.get(PEConfiguration.getBaseFolder().toString() + File.separator+ bugChangeList.getBugId() + "_" + e.getKey() + "_" + ".json").toFile();
try {
  FileUtil.writeToFile(json_file, gaResxSource.get(e.getKey()).toString());
} catch (IOException exception) {
  exception.printStackTrace();

相关文章