本文整理了Java中com.google.common.io.Files.getNameWithoutExtension()
方法的一些代码示例,展示了Files.getNameWithoutExtension()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.getNameWithoutExtension()
方法的具体详情如下:
包路径:com.google.common.io.Files
类名称:Files
方法名:getNameWithoutExtension
[英]Returns the file name without its file extension or path. This is similar to the basename unix command. The result does not include the ' .'.
[中]返回不带file extension或路径的文件名。这类似于basename unix命令。结果不包括“.”。
代码示例来源:origin: apache/incubator-gobblin
public static String getSpecName(Path specUri) {
return Files.getNameWithoutExtension(specUri.getName());
}
代码示例来源:origin: apache/incubator-druid
@Override
public String getName()
{
final String ext = Files.getFileExtension(path);
return Files.getNameWithoutExtension(path) + (Strings.isNullOrEmpty(ext) ? "" : ("." + ext));
}
代码示例来源:origin: JesusFreke/smali
public FilenameVdexProvider(File oatFile) {
File oatParent = oatFile.getAbsoluteFile().getParentFile();
String baseName = Files.getNameWithoutExtension(oatFile.getAbsolutePath());
vdexFile = new File(oatParent, baseName + ".vdex");
}
代码示例来源:origin: azkaban/azkaban
public String getFlowName(final File flowFile) {
checkArgument(flowFile != null && flowFile.exists());
checkArgument(flowFile.getName().endsWith(Constants.FLOW_FILE_SUFFIX));
return Files.getNameWithoutExtension(flowFile.getName());
}
}
代码示例来源:origin: prestodb/presto
public BenchmarkQuery(File file)
throws IOException
{
requireNonNull(file, "file is null");
name = Files.getNameWithoutExtension(file.getName());
// file can have 2 sections separated by a line of equals signs
String text = Files.toString(file, StandardCharsets.UTF_8);
List<String> sections = SECTION_SPLITTER.splitToList(text);
if (sections.size() == 2) {
this.tags = ImmutableMap.copyOf(TAGS_SPLITTER.split(sections.get(0)));
this.sql = sections.get(1);
}
else {
// no tags
this.tags = ImmutableMap.of();
this.sql = sections.get(0);
}
}
代码示例来源:origin: apache/incubator-gobblin
/**
* Construct a new file path by appending record count to the filename of the given file path, separated by SEPARATOR.
* For example, given path: "/a/b/c/file.avro" and record count: 123,
* the new path returned will be: "/a/b/c/file.123.avro"
*/
public static String constructFilePath(String oldFilePath, long recordCounts) {
return new Path(new Path(oldFilePath).getParent(), Files.getNameWithoutExtension(oldFilePath).toString() + SEPARATOR
+ recordCounts + SEPARATOR + Files.getFileExtension(oldFilePath)).toString();
}
代码示例来源:origin: apache/incubator-druid
/**
* Get the file name without the .gz extension
*
* @param fname The name of the gzip file
*
* @return fname without the ".gz" extension
*
* @throws IAE if fname is not a valid "*.gz" file name
*/
public static String getGzBaseName(String fname)
{
final String reducedFname = Files.getNameWithoutExtension(fname);
if (isGz(fname) && !reducedFname.isEmpty()) {
return reducedFname;
}
throw new IAE("[%s] is not a valid gz file name", fname);
}
代码示例来源:origin: prestodb/presto
private void loadCatalog(File file)
throws Exception
{
String catalogName = Files.getNameWithoutExtension(file.getName());
if (disabledCatalogs.contains(catalogName)) {
log.info("Skipping disabled catalog %s", catalogName);
return;
}
log.info("-- Loading catalog %s --", file);
Map<String, String> properties = new HashMap<>(loadProperties(file));
String connectorName = properties.remove("connector.name");
checkState(connectorName != null, "Catalog configuration %s does not contain connector.name", file.getAbsoluteFile());
connectorManager.createConnection(catalogName, connectorName, ImmutableMap.copyOf(properties));
log.info("-- Added catalog %s using connector %s --", catalogName, connectorName);
}
代码示例来源:origin: apache/incubator-gobblin
/**
* The job template name is derived from the {@link org.apache.gobblin.runtime.api.JobTemplate} URI. It is the
* simple name of the path component of the URI.
* @param jobExecutionPlan
* @return the simple name of the job template from the URI of its path.
*/
private static String getJobTemplateName(JobExecutionPlan jobExecutionPlan) {
Optional<URI> jobTemplateUri = jobExecutionPlan.getJobSpec().getTemplateURI();
if (jobTemplateUri.isPresent()) {
return Files.getNameWithoutExtension(new Path(jobTemplateUri.get()).getName());
} else {
return null;
}
}
代码示例来源:origin: google/guava
public void testGetNameWithoutExtension() {
assertEquals("", Files.getNameWithoutExtension(".txt"));
assertEquals("blah", Files.getNameWithoutExtension("blah.txt"));
assertEquals("blah.", Files.getNameWithoutExtension("blah..txt"));
assertEquals(".blah", Files.getNameWithoutExtension(".blah.txt"));
assertEquals("blah", Files.getNameWithoutExtension("/tmp/blah.txt"));
assertEquals("blah.tar", Files.getNameWithoutExtension("blah.tar.gz"));
assertEquals("", Files.getNameWithoutExtension("/"));
assertEquals("", Files.getNameWithoutExtension("."));
assertEquals(".", Files.getNameWithoutExtension(".."));
assertEquals("..", Files.getNameWithoutExtension("..."));
assertEquals("blah", Files.getNameWithoutExtension("blah"));
assertEquals("blah", Files.getNameWithoutExtension("blah."));
assertEquals(".blah", Files.getNameWithoutExtension(".blah."));
assertEquals("blah", Files.getNameWithoutExtension("/foo.bar/blah"));
assertEquals("blah", Files.getNameWithoutExtension("/foo/.bar/blah"));
}
代码示例来源:origin: apache/incubator-gobblin
/**
* Helper that overrides the flow edge properties with name derived from the edge file path
* @param edgeConfig edge config
* @param edgeFilePath path of the edge file
* @return config with overridden edge properties
*/
private Config getEdgeConfigWithOverrides(Config edgeConfig, Path edgeFilePath) {
String source = edgeFilePath.getParent().getParent().getName();
String destination = edgeFilePath.getParent().getName();
String edgeName = Files.getNameWithoutExtension(edgeFilePath.getName());
return edgeConfig.withValue(FlowGraphConfigurationKeys.FLOW_EDGE_SOURCE_KEY, ConfigValueFactory.fromAnyRef(source))
.withValue(FlowGraphConfigurationKeys.FLOW_EDGE_DESTINATION_KEY, ConfigValueFactory.fromAnyRef(destination))
.withValue(FlowGraphConfigurationKeys.FLOW_EDGE_ID_KEY, ConfigValueFactory.fromAnyRef(getEdgeId(source, destination, edgeName)));
}
代码示例来源:origin: runelite/runelite
File hashFile = new File(scriptDirectory, Files.getNameWithoutExtension(scriptFile.getName()) + ".hash");
if (hashFile.exists())
代码示例来源:origin: apache/incubator-druid
@Test
public void simpleDirectoryTest() throws IOException, SegmentLoadingException
{
File srcDir = temporaryFolder.newFolder();
File tmpFile = File.createTempFile("test", "file", srcDir);
File expectedOutput = new File(tmpDir, Files.getNameWithoutExtension(tmpFile.getAbsolutePath()));
Assert.assertFalse(expectedOutput.exists());
puller.getSegmentFiles(srcDir, tmpDir);
Assert.assertTrue(expectedOutput.exists());
}
}
代码示例来源:origin: apache/incubator-druid
@Test
public void simpleGZTest() throws IOException, SegmentLoadingException
{
File zipFile = File.createTempFile("gztest", ".gz");
File unZipFile = new File(
tmpDir,
Files.getNameWithoutExtension(
zipFile.getAbsolutePath()
)
);
unZipFile.delete();
zipFile.delete();
try (OutputStream fOutStream = new FileOutputStream(zipFile)) {
try (OutputStream outputStream = new GZIPOutputStream(fOutStream)) {
outputStream.write(new byte[0]);
outputStream.flush();
}
}
Assert.assertTrue(zipFile.exists());
Assert.assertFalse(unZipFile.exists());
puller.getSegmentFiles(zipFile, tmpDir);
Assert.assertTrue(unZipFile.exists());
}
代码示例来源:origin: google/error-prone
return Description.NO_MATCH;
String filename = Files.getNameWithoutExtension(ASTHelpers.getFileName(tree));
List<String> names = new ArrayList<>();
for (Tree member : tree.getTypeDecls()) {
代码示例来源:origin: apache/incubator-druid
final String fname = Files.getNameWithoutExtension(uri.getPath());
final File outFile = new File(outDir, fname);
代码示例来源:origin: apache/incubator-gobblin
Pattern.compile(Pattern.quote(Files.getNameWithoutExtension(originalFilename)) + suffixPattern + "\\.avro");
Path secondOutput = lateFileRecordCountProvider.constructLateFilePath(firstOutput.getName(), fs, testDir);
Assert.assertEquals(testDir, secondOutput.getParent());
Pattern.compile(Files.getNameWithoutExtension(originalFilename) + suffixPattern + suffixPattern + "\\.avro");
Path thirdOutput = lateFileRecordCountProvider.constructLateFilePath(secondOutput.getName(), fs, testDir);
Assert.assertEquals(testDir, thirdOutput.getParent());
代码示例来源:origin: CalebFenton/simplify
if (simplifyOpts.getOutFile() == null) {
String fileName = simplifyOpts.getInFile().toString();
String baseName = Files.getNameWithoutExtension(fileName);
String outFileName = baseName + "_simple";
代码示例来源:origin: apache/incubator-gobblin
URI topologySpecUri = new URI(Files.getNameWithoutExtension(fileStatus.getPath().getName()));
Config topologyConfig = ConfigFactory.parseFile(new File(PathUtils.getPathWithoutSchemeAndAuthority(fileStatus.getPath()).toString()));
Class specExecutorClass = Class.forName(topologyConfig.getString(ServiceConfigKeys.SPEC_EXECUTOR_KEY));
代码示例来源:origin: apache/incubator-gobblin
String jobSpecUri = Files.getNameWithoutExtension(new Path(jobTemplate.getUri()).getName());
jobExecutionPlans.add(new JobExecutionPlan(JobSpec.builder(jobSpecUri).withConfig(jobTemplate.getRawTemplateConfig()).
withVersion("1").withTemplate(jobTemplate.getUri()).build(), specExecutor));
内容来源于网络,如有侵权,请联系作者删除!