當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtil.fileSystemSafe方法代碼示例

本文整理匯總了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;
    }
 
開發者ID:sindremehus,項目名稱:subsonic,代碼行數:26,代碼來源:PodcastService.java

示例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;
}
 
開發者ID:sindremehus,項目名稱:subsonic,代碼行數:17,代碼來源:PodcastService.java

示例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;
    }
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:38,代碼來源:PodcastService.java

示例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.");
        
    	}    			
    	
    }
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:17,代碼來源:PlaylistService.java


注:本文中的net.sourceforge.subsonic.util.StringUtil.fileSystemSafe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。