本文整理了Java中slash.common.io.Transfer.encodeFileName()
方法的一些代码示例,展示了Transfer.encodeFileName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transfer.encodeFileName()
方法的具体详情如下:
包路径:slash.common.io.Transfer
类名称:Transfer
方法名:encodeFileName
暂无
代码示例来源:origin: cpesch/RouteConverter
public Route createRoute(String description, File localFile) throws IOException {
File destination = new File(directory, encodeFileName(description));
try (InputStream inputStream = new FileInputStream(localFile); OutputStream outputStream = new FileOutputStream(destination)) {
copyLarge(inputStream, outputStream, new byte[DEFAULT_BUFFER_SIZE]);
}
return new LocalRoute(destination);
}
代码示例来源:origin: cpesch/RouteConverter
public Route createRoute(String description, String url) throws IOException {
File destination = new File(directory, encodeFileName(description));
try (PrintWriter writer = new PrintWriter(destination, UTF8_ENCODING)) {
writer.println("[InternetShortcut]");
writer.println("URL=" + url);
}
return new LocalRoute(destination);
}
代码示例来源:origin: cpesch/RouteConverter
public void update(Category parent, String name) throws IOException {
File newParent;
String newName = encodeFileName(name);
try {
newParent = parent != null ? new File(new URL(parent.getHref()).toURI()) : directory.getParentFile();
} catch (URISyntaxException e) {
throw new IOException(format("Cannot rename %s for %s and %s", directory, parent, name));
}
File newDirectory = new File(newParent, newName);
if (!directory.renameTo(newDirectory))
throw new IOException(format("Cannot rename %s to %s", directory, newDirectory));
this.directory = newDirectory;
}
代码示例来源:origin: cpesch/RouteConverter
public void update(Category parent, String description) throws IOException {
File category = toFile(new URL(parent.getHref()));
File newName = new File(category, encodeFileName(description));
if (newName.exists())
throw new DuplicateNameException(format("%s %s already exists", newName.isDirectory() ? "Category" : "Route", description), newName.getAbsolutePath());
if (!file.renameTo(newName))
throw new IOException(format("Cannot rename %s to %s", file, newName));
file = newName;
}
代码示例来源:origin: cpesch/RouteConverter
public Category create(String name) throws IOException {
if (name.contains("/") || name.contains(separator))
throw new ForbiddenException(format("Cannot have slashes in name %s", name), getHref());
File subDirectory = new File(directory, encodeFileName(name));
if (subDirectory.exists())
throw new DuplicateNameException(format("%s %s already exists", subDirectory.isDirectory() ? "Category" : "Route", name), subDirectory.getAbsolutePath());
if (!subDirectory.mkdir())
throw new IOException(format("Cannot create category %s", subDirectory));
return new LocalCategory(catalog, subDirectory);
}
代码示例来源:origin: cpesch/RouteConverter
@Test
public void testEncodeFileName() {
String original = ".A/B\\C:D.";
String expected = "%2eA%2fB%5cC%3aD.";
assertEquals(expected, encodeFileName(original));
assertEquals(original, decodeUri(expected));
}
}
内容来源于网络,如有侵权,请联系作者删除!