本文整理汇总了Java中com.google.common.io.Files.getNameWithoutExtension方法的典型用法代码示例。如果您正苦于以下问题:Java Files.getNameWithoutExtension方法的具体用法?Java Files.getNameWithoutExtension怎么用?Java Files.getNameWithoutExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.Files
的用法示例。
在下文中一共展示了Files.getNameWithoutExtension方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCutList
import com.google.common.io.Files; //导入方法依赖的package包/类
private boolean loadCutList(IMediaDetails details)
{
try {
File cutFile = new File(details.getMediaFile().getParent(), Files.getNameWithoutExtension(details.getMediaFile().getAbsolutePath()) + ".cut");
if (cutFile.exists()) {
List<String> jumpSegments = Files.asCharSource(cutFile, Charset.forName("UTF-8")).readLines();
details.getExtendedDetails().putIfAbsent("CutList", jumpSegments);
return true;
} else {
logger.warn("CutList not located.");
}
} catch (IOException ioe) {
logger.error(ioe.getMessage(), ioe);
}
return false;
}
示例2: getSongType
import com.google.common.io.Files; //导入方法依赖的package包/类
public String getSongType() {
String baseName = Files.getNameWithoutExtension(file);
if(baseName.endsWith("#blurb")) {
return "blurb";
}
else if(baseName.endsWith("#commercial")) {
return "commercial";
}
else if(baseName.endsWith("#talk")) {
return "talk";
}
return "music";
}
示例3: cleanup
import com.google.common.io.Files; //导入方法依赖的package包/类
/**
* Remove all temporary files created while processing the media file
*/
@SuppressWarnings("squid:S899")
private void cleanup(IMediaDetails details)
{
// Paranoia, never erase the root directory!
if (this.tmpDir.isEmpty() || this.tmpDir.equals("/"))
return;
try {
Path rootPath = Paths.get(this.tmpDir);
java.nio.file.Files.walk(rootPath)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
// If we had a preserved CutList from the original CommercialDetect, clean it up as it's no longer valid
File cutFile = new File(details.getMediaFile().getParent(), Files.getNameWithoutExtension(details.getMediaFile().getAbsolutePath()) + ".cut");
if (cutFile.exists())
cutFile.delete();
} catch (IOException ioe) {
logger.error(ioe.getMessage());
}
}
示例4: getUniqueContentName
import com.google.common.io.Files; //导入方法依赖的package包/类
/**
* Returns a unique name for a file with a given content hash.
*
* <p>Directory paths are removed. Example:
* <pre>
* dir="a/b/c/d", contentHash="f000" => d-f000.jar
* file="a/b/c/d.txt", contentHash="f000" => d-f000.txt
* file="a/b/c/d", contentHash="f000" => d-f000
* </pre>
*/
private static String getUniqueContentName(File classpathElement, String contentHash) {
String fileName = Files.getNameWithoutExtension(classpathElement.getAbsolutePath());
String fileExtension = Files.getFileExtension(classpathElement.getAbsolutePath());
if (classpathElement.isDirectory()) {
return fileName + "-" + contentHash + ".jar";
} else if (fileExtension.isEmpty()) {
return fileName + "-" + contentHash;
}
return fileName + "-" + contentHash + "." + fileExtension;
}
示例5: loadJsonResourceFiles
import com.google.common.io.Files; //导入方法依赖的package包/类
public static <T extends NamedTest> List<T> loadJsonResourceFiles(String packageName, Class<T> cls) throws IOException {
// Preconditions.checkNotNull(packageName, "packageName cannot be null");
Reflections reflections = new Reflections(packageName, new ResourcesScanner());
Set<String> resources = reflections.getResources(new FilterBuilder.Include(".*"));
List<T> datas = new ArrayList<>(resources.size());
Path packagePath = Paths.get("/" + packageName.replace(".", "/"));
for (String resource : resources) {
log.trace("Loading resource {}", resource);
Path resourcePath = Paths.get("/" + resource);
Path relativePath = packagePath.relativize(resourcePath);
File resourceFile = new File("/" + resource);
T data;
try (InputStream inputStream = cls.getResourceAsStream(resourceFile.getAbsolutePath())) {
data = ObjectMapperFactory.INSTANCE.readValue(inputStream, cls);
} catch (IOException ex) {
if (log.isErrorEnabled()) {
log.error("Exception thrown while loading {}", resourcePath, ex);
}
throw ex;
}
String nameWithoutExtension = Files.getNameWithoutExtension(resource);
if (null != relativePath.getParent()) {
String parentName = relativePath.getParent().getFileName().toString();
data.testName(parentName + "/" + nameWithoutExtension);
} else {
data.testName(nameWithoutExtension);
}
datas.add(data);
}
return datas;
}
示例6: getName
import com.google.common.io.Files; //导入方法依赖的package包/类
public String getName() {
String baseName = Files.getNameWithoutExtension(file);
String type = getSongType();
if(type.equals("music")) {
return baseName;
}
else {
return baseName.substring(0, baseName.length() - type.length() - 1);
}
}
示例7: cleanup
import com.google.common.io.Files; //导入方法依赖的package包/类
@SuppressWarnings("squid:S899")
void cleanup(IMediaDetails details) {
List<String> tempExtensions = ImmutableList.of(".cut", ".txt", ".VPrj");
for (String ext : tempExtensions) {
if (this.saveCutList && ext.endsWith(".cut"))
continue;
File cutFile = new File(details.getMediaFile().getParent(), Files.getNameWithoutExtension(details.getMediaFile().getAbsolutePath()) + ext);
if (cutFile.exists())
cutFile.delete();
}
}
示例8: getNameWithoutExtension
import com.google.common.io.Files; //导入方法依赖的package包/类
/**
* Get the name of the specified file without the extension.
*
* @param file The file
* @return The name of the file without the file extension
*/
public static String getNameWithoutExtension(String file) {
return Files.getNameWithoutExtension(file);
}