本文整理匯總了Java中net.sourceforge.subsonic.util.StringUtil.fileSystemSafe方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil.fileSystemSafe方法的具體用法?Java StringUtil.fileSystemSafe怎麽用?Java StringUtil.fileSystemSafe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sourceforge.subsonic.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.fileSystemSafe方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFile
import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
private synchronized File getFile(PodcastChannel channel, PodcastEpisode episode) {
File channelDir = getChannelDirectory(channel);
String filename = StringUtil.getUrlFile(episode.getUrl());
if (filename == null) {
filename = episode.getTitle();
}
filename = StringUtil.fileSystemSafe(filename);
String extension = FilenameUtils.getExtension(filename);
filename = FilenameUtils.removeExtension(filename);
if (StringUtils.isBlank(extension)) {
extension = "mp3";
}
File file = new File(channelDir, filename + "." + extension);
for (int i = 0; file.exists(); i++) {
file = new File(channelDir, filename + i + "." + extension);
}
if (!securityService.isWriteAllowed(file)) {
throw new SecurityException("Access denied to file " + file);
}
return file;
}
示例2: getChannelDirectory
import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
private File getChannelDirectory(PodcastChannel channel) {
File podcastDir = new File(settingsService.getPodcastFolder());
File channelDir = new File(podcastDir, StringUtil.fileSystemSafe(channel.getTitle()));
if (!channelDir.exists()) {
boolean ok = channelDir.mkdirs();
if (!ok) {
throw new RuntimeException("Failed to create directory " + channelDir);
}
MediaFile mediaFile = mediaFileService.getMediaFile(channelDir);
mediaFile.setComment(channel.getDescription());
mediaFileService.updateMediaFile(mediaFile);
}
return channelDir;
}
示例3: getFile
import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
private synchronized File getFile(PodcastChannel channel, PodcastEpisode episode) {
File podcastDir = new File(settingsService.getPodcastFolder());
File channelDir = new File(podcastDir, StringUtil.fileSystemSafe(channel.getTitle()));
if (!channelDir.exists()) {
boolean ok = channelDir.mkdirs();
if (!ok) {
throw new RuntimeException("Failed to create directory " + channelDir);
}
MediaFile mediaFile = mediaFileService.getMediaFile(channelDir);
mediaFile.setComment(channel.getDescription());
mediaFileService.updateMediaFile(mediaFile);
}
String filename = StringUtil.getUrlFile(episode.getUrl());
if (filename == null) {
filename = episode.getTitle();
}
filename = StringUtil.fileSystemSafe(filename);
String extension = FilenameUtils.getExtension(filename);
filename = FilenameUtils.removeExtension(filename);
if (StringUtils.isBlank(extension)) {
extension = "mp3";
}
File file = new File(channelDir, filename + "." + extension);
for (int i = 0; file.exists(); i++) {
file = new File(channelDir, filename + i + "." + extension);
}
if (!securityService.isWriteAllowed(file)) {
throw new SecurityException("Access denied to file " + file);
}
return file;
}
示例4: exportAllPlaylists
import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
public void exportAllPlaylists() throws Exception {
String playlistExportFolderPath = settingsService.getPlaylistExportFolder();
for (Playlist playlist : playlistDao.getAllPlaylists()) {
FileWriter fstream = new FileWriter(playlistExportFolderPath + "/" + StringUtil.fileSystemSafe(playlist.getName()) + ".m3u8");
BufferedWriter outPlaylist = new BufferedWriter(fstream);
new M3UFormat().format(getFilesInPlaylist(playlist.getId()), outPlaylist);
outPlaylist.close();
LOG.info("## Completed export of " + playlistDao.getAllPlaylists().size() + " playlists to folder " + playlistExportFolderPath);
// LOG.warn("Failed to export playlists.");
}
}