org.codehaus.plexus.util.FileUtils.fileRead()方法的使用及代码示例

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

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

FileUtils.fileRead介绍

[英]Note: the file content is read with platform encoding
[中]

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Note: the file content is read with platform encoding
 *
 * @param file the file path
 * @return the file content using the platform encoding.
 * @throws IOException if any
 */
public static String fileRead( File file )
  throws IOException
{
  return fileRead( file, null );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Note: the file content is read with platform encoding.
 *
 * @param file the file path
 * @return the file content using the platform encoding.
 * @throws IOException if any
 */
public static String fileRead( String file )
  throws IOException
{
  return fileRead( file, null );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * @param file the file path
 * @param encoding the wanted encoding
 * @return the file content using the specified encoding.
 * @throws IOException if any
 */
public static String fileRead( String file, String encoding )
  throws IOException
{
  return fileRead( new File( file ), encoding );
}

代码示例来源:origin: apache/maven

wagon.get( remotePath + checksumFileExtension, tempChecksumFile );
String expectedChecksum = FileUtils.fileRead( tempChecksumFile, "UTF-8" );

代码示例来源:origin: apache/avro

public void testIdlProtocolMojoJoda() throws Exception {
 IDLProtocolMojo mojo = (IDLProtocolMojo) lookupMojo("idl-protocol", jodaTestPom);
 assertNotNull(mojo);
 mojo.execute();
 File outputDir = new File(getBasedir(), "target/test-harness/idl-joda/test");
 String[] generatedFileNames = new String[]{"IdlPrivacy.java",
  "IdlTest.java", "IdlUser.java", "IdlUserWrapper.java"};
 String idlUserContent = FileUtils.fileRead(new File(outputDir, "IdlUser.java"));
 assertTrue(idlUserContent.contains("org.joda.time.DateTime"));
}

代码示例来源:origin: apache/avro

public void testIdlProtocolMojoJsr310() throws Exception {
  IDLProtocolMojo mojo = (IDLProtocolMojo) lookupMojo("idl-protocol", jsr310TestPom);

  assertNotNull(mojo);
  mojo.execute();

  File outputDir = new File(getBasedir(), "target/test-harness/idl-jsr310/test");
  String[] generatedFileNames = new String[]{"IdlPrivacy.java",
   "IdlTest.java", "IdlUser.java", "IdlUserWrapper.java"};

  String idlUserContent = FileUtils.fileRead(new File(outputDir, "IdlUser.java"));
  assertTrue(idlUserContent.contains("java.time.Instant"));
 }
}

代码示例来源:origin: apache/avro

public void testProtocolMojoJsr310() throws Exception {
  ProtocolMojo mojo = (ProtocolMojo) lookupMojo("protocol", jsr310TestPom);

  assertNotNull(mojo);
  mojo.execute();

  File outputDir = new File(getBasedir(), "target/test-harness/protocol-jsr310/test");
  String[] generatedFiles = new String[]{"ProtocolPrivacy.java",
      "ProtocolTest.java", "ProtocolUser.java"};

  assertFilesExist(outputDir, generatedFiles);

  String protocolUserContent = FileUtils.fileRead(new File(outputDir, "ProtocolUser.java"));
  assertTrue(protocolUserContent.contains("java.time.Instant"));
 }
}

代码示例来源:origin: apache/avro

public void testSchemaMojoJoda() throws Exception {
 SchemaMojo mojo = (SchemaMojo) lookupMojo("schema", jodaTestPom);
 assertNotNull(mojo);
 mojo.execute();
 File outputDir = new File(getBasedir(), "target/test-harness/schema-joda/test");
 String[] generatedFiles = new String[]{"PrivacyDirectImport.java",
  "PrivacyImport.java", "SchemaPrivacy.java", "SchemaUser.java"};
 assertFilesExist(outputDir, generatedFiles);
 String schemaUserContent = FileUtils.fileRead(new File(outputDir, "SchemaUser.java"));
 assertTrue(schemaUserContent.contains("org.joda.time.DateTime"));
}

代码示例来源:origin: apache/avro

public void testSchemaMojoJsr310() throws Exception {
  SchemaMojo mojo = (SchemaMojo) lookupMojo("schema", jsr310TestPom);

  assertNotNull(mojo);
  mojo.execute();

  File outputDir = new File(getBasedir(), "target/test-harness/schema-jsr310/test");
  String[] generatedFiles = new String[]{"PrivacyDirectImport.java",
      "PrivacyImport.java", "SchemaPrivacy.java", "SchemaUser.java"};

  assertFilesExist(outputDir, generatedFiles);

  String schemaUserContent = FileUtils.fileRead(new File(outputDir, "SchemaUser.java"));
  assertTrue(schemaUserContent.contains("java.time.Instant"));
 }
}

代码示例来源:origin: apache/avro

public void testProtocolMojoJoda() throws Exception {
 ProtocolMojo mojo = (ProtocolMojo) lookupMojo("protocol", jodaTestPom);
 assertNotNull(mojo);
 mojo.execute();
 File outputDir = new File(getBasedir(), "target/test-harness/protocol-joda/test");
 String[] generatedFiles = new String[]{"ProtocolPrivacy.java",
  "ProtocolTest.java", "ProtocolUser.java"};
 assertFilesExist(outputDir, generatedFiles);
 String protocolUserContent = FileUtils.fileRead(new File(outputDir, "ProtocolUser.java"));
 assertTrue(protocolUserContent.contains("org.joda.time.DateTime"));
}

代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

public static void assertFileContents( File basedir, String expectedPath, String actualPath )
  throws IOException
{
  String expected = FileUtils.fileRead( new File( basedir, expectedPath ) );
  String actual = FileUtils.fileRead( new File( basedir, actualPath ) );
  Assert.assertEquals( expected, actual );
}

代码示例来源:origin: takari/polyglot-maven

if (!dumpPom.exists() || !FileUtils.fileRead(dumpPom).equals(xml.toString().replace("?>", WARNING))) {
 dumpPom.setWritable(true);
 FileUtils.fileWrite(dumpPom, xml.toString().replace("?>", WARNING));

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Note: the file content is read with platform encoding
 */
public static String fileRead( String file )
  throws IOException
{
  return fileRead( file, null );
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Note: the file content is read with platform encoding
 */
public static String fileRead( File file )
  throws IOException
{
  return fileRead( file, null);
}

代码示例来源:origin: jenkinsci/acceptance-test-harness

private static String getConfigFileContent(){
  String configFile = System.getProperty("CONFIG");
  if(configFile != null){
    try {
      return FileUtils.fileRead(configFile);
    } catch (IOException e) {
      return "config";
    }
  }else{
    return "config";
  }
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

public static String fileRead( String file, String encoding )
  throws IOException
{
  return fileRead( new File( file ), encoding );
}

代码示例来源:origin: jenkinsci/acceptance-test-harness

@Override
public void diagnose(Throwable cause) throws IOException {
  out.println("Error: "+cause.getMessage());
  cause.printStackTrace();
  out.println("It looks like there was an error, here's the console from Jenkins:");
  out.println("--------------------------------------------------------------------------");
  out.println(FileUtils.fileRead(logFile));
}

代码示例来源:origin: org.apache.maven.wagon/wagon-tck-http

public static void assertFileContentsFromResource( final String resourceBase, final String resourceName,
                          final File output, final String whyWouldItFail )
  throws IOException
{
  String content = readResource( resourceBase, resourceName );
  String test = fileRead( output );
  assertEquals( whyWouldItFail, content, test );
}

代码示例来源:origin: apache/maven-wagon

public static void assertFileContentsFromResource( final String resourceBase, final String resourceName,
                          final File output, final String whyWouldItFail )
  throws IOException
{
  String content = readResource( resourceBase, resourceName );
  String test = fileRead( output );
  assertEquals( whyWouldItFail, content, test );
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-test

protected void assertFile( File root, String fileName )
  throws Exception
{
  File file = new File( root, fileName );
  assertTrue( "Missing file: '" + file.getAbsolutePath() + "'.", file.exists() );
  assertTrue( "File isn't a file: '" + file.getAbsolutePath() + "'.", file.isFile() );
  String expected = fileName;
  String actual = FileUtils.fileRead( file );
  assertEquals( "The file doesn't contain the expected contents. File: " + file.getAbsolutePath(), expected,
         actual );
}

相关文章