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


Java StringUtil.readLines方法代碼示例

本文整理匯總了Java中net.sourceforge.subsonic.util.StringUtil.readLines方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil.readLines方法的具體用法?Java StringUtil.readLines怎麽用?Java StringUtil.readLines使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sourceforge.subsonic.util.StringUtil的用法示例。


在下文中一共展示了StringUtil.readLines方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAvailableThemes

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
/**
 * Returns a list of available themes.
 *
 * @return A list of available themes.
 */
public synchronized Theme[] getAvailableThemes() {
    if (themes == null) {
        themes = new ArrayList<Theme>();
        try {
            InputStream in = SettingsService.class.getResourceAsStream(THEMES_FILE);
            String[] lines = StringUtil.readLines(in);
            for (String line : lines) {
                String[] elements = StringUtil.split(line);
                if (elements.length == 2) {
                    themes.add(new Theme(elements[0], elements[1]));
                } else if (elements.length == 3) {
                    themes.add(new Theme(elements[0], elements[1], elements[2]));
                } else {
                    LOG.warn("Failed to parse theme from line: [" + line + "].");
                }
            }
        } catch (IOException x) {
            LOG.error("Failed to resolve list of themes.", x);
            themes.add(new Theme("default", "Subsonic default"));
        }
    }
    return themes.toArray(new Theme[themes.size()]);
}
 
開發者ID:sindremehus,項目名稱:subsonic,代碼行數:29,代碼來源:SettingsService.java

示例2: getAvailableLocales

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
/**
 * Returns a list of available locales.
 *
 * @return A list of available locales.
 */
public synchronized Locale[] getAvailableLocales() {
    if (locales == null) {
        locales = new ArrayList<Locale>();
        try {
            InputStream in = SettingsService.class.getResourceAsStream(LOCALES_FILE);
            String[] lines = StringUtil.readLines(in);

            for (String line : lines) {
                locales.add(parseLocale(line));
            }

        } catch (IOException x) {
            LOG.error("Failed to resolve list of locales.", x);
            locales.add(Locale.ENGLISH);
        }
    }
    return locales.toArray(new Locale[locales.size()]);
}
 
開發者ID:sindremehus,項目名稱:subsonic,代碼行數:24,代碼來源:SettingsService.java

示例3: isExcluded

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
/**
    * Returns whether the given file is excluded, i.e., whether it is listed in 'futuresonic_exclude.txt' in
    * the current directory.
    *
    * @param file The child file in question.
    * @return Whether the child file is excluded.
    */	 
private boolean isExcluded(File file) throws IOException {

       if (file.getName().startsWith(".") || file.getName().startsWith("@eaDir") || file.getName().toLowerCase().equals("thumbs.db") || file.getName().toLowerCase().equals("extrafanart") ) {
           return true;
       }

       File excludeFile = new File(file.getParentFile().getPath(), "futuresonic_exclude.txt");
       if (excludeFile.exists()) {
           excludes = new HashSet<String>();
	
   		LOG.debug("## excludeFile found: " + excludeFile);
           String[] lines = StringUtil.readLines(new FileInputStream(excludeFile));
           for (String line : lines) {
               excludes.add(line.toLowerCase());
           }
		return excludes.contains(file.getName().toLowerCase());		
       }
       
   return false;    
   }
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:28,代碼來源:MediaFileService.java

示例4: getAvailableThemes

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
/**
 * Returns a list of available themes.
 *
 * @return A list of available themes.
 */
public synchronized Theme[] getAvailableThemes() {
    if (themes == null) {
        themes = new ArrayList<Theme>();
        try {
            InputStream in = SettingsService.class.getResourceAsStream(THEMES_FILE);
            String[] lines = StringUtil.readLines(in);
            for (String line : lines) {
                String[] elements = StringUtil.split(line);
                if (elements.length == 2) {
                    themes.add(new Theme(elements[0], elements[1]));
                } else {
                    LOG.warn("Failed to parse theme from line: [" + line + "].");
                }
            }
        } catch (IOException x) {
            LOG.error("Failed to resolve list of themes.", x);
            themes.add(new Theme("default", "Subsonic default"));
        }
    }
    return themes.toArray(new Theme[themes.size()]);
}
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:27,代碼來源:SettingsService.java

示例5: isExcluded

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
/**
    * Returns whether the given file is excluded, i.e., whether it is listed in 'madsonic_exclude.txt' in
    * the current directory.
    *
    * @param file The child file in question.
    * @return Whether the child file is excluded.
    */	 
private boolean isExcluded(File file) throws IOException {

       if (file.getName().startsWith(".") || file.getName().startsWith("@eaDir") || file.getName().toLowerCase().equals("thumbs.db") || file.getName().toLowerCase().equals("extrafanart") ) {
           return true;
       }

       File excludeFile = new File(file.getParentFile().getPath(), "madsonic_exclude.txt");
       if (excludeFile.exists()) {
           excludes = new HashSet<String>();
	
   		LOG.debug("## excludeFile found: " + excludeFile);
           String[] lines = StringUtil.readLines(new FileInputStream(excludeFile));
           for (String line : lines) {
               excludes.add(line.toLowerCase());
           }
		return excludes.contains(file.getName().toLowerCase());		
       }
       
   return false;    
   }
 
開發者ID:MadMarty,項目名稱:madsonic-server-5.0,代碼行數:28,代碼來源:MediaFileService.java

示例6: getRawMetaData

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
/**
 * Parses meta data for the given music file. No guessing or reformatting is done.
 *
 *
 * @param file The music file to parse.
 * @return Meta data for the file.
 */
@Override
public MetaData getRawMetaData(File file) {

    MetaData metaData = new MetaData();

    try {

        File ffmpeg = new File(transcodingService.getTranscodeDirectory(), "ffmpeg");

        String[] command = new String[]{ffmpeg.getAbsolutePath(), "-i", file.getAbsolutePath()};
        Process process = Runtime.getRuntime().exec(command);
        InputStream stdout = process.getInputStream();
        InputStream stderr = process.getErrorStream();

        // Consume stdout, we're not interested in that.
        new InputStreamReaderThread(stdout, "ffmpeg", true).start();

        // Read everything from stderr.  It will contain text similar to:
        // Input #0, avi, from 'foo.avi':
        //   Duration: 00:00:33.90, start: 0.000000, bitrate: 2225 kb/s
        //     Stream #0.0: Video: mpeg4, yuv420p, 352x240 [PAR 1:1 DAR 22:15], 29.97 fps, 29.97 tbr, 29.97 tbn, 30k tbc
        //     Stream #0.1: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
        String[] lines = StringUtil.readLines(stderr);

        Integer width = null;
        Integer height = null;
        Double par = 1.0;
        for (String line : lines) {

            Matcher matcher = DURATION_PATTERN.matcher(line);
            if (matcher.find()) {
                int hours = Integer.parseInt(matcher.group(1));
                int minutes = Integer.parseInt(matcher.group(2));
                int seconds = Integer.parseInt(matcher.group(3));
                metaData.setDurationSeconds(hours * 3600 + minutes * 60 + seconds);
            }

            matcher = BITRATE_PATTERN.matcher(line);
            if (matcher.find()) {
                metaData.setBitRate(Integer.valueOf(matcher.group(1)));
            }

            matcher = DIMENSION_PATTERN.matcher(line);
            if (matcher.find()) {
                width = Integer.valueOf(matcher.group(1));
                height = Integer.valueOf(matcher.group(2));
            }

            // PAR = Pixel Aspect Rate
            matcher = PAR_PATTERN.matcher(line);
            if (matcher.find()) {
                int a = Integer.parseInt(matcher.group(1));
                int b = Integer.parseInt(matcher.group(2));
                if (a > 0 && b > 0) {
                    par = (double) a / (double) b;
                }
            }
        }

        if (width != null && height != null) {
            width = (int) Math.round(width.doubleValue() * par);
            metaData.setWidth(width);
            metaData.setHeight(height);
        }


    } catch (Throwable x) {
        LOG.warn("Error when parsing metadata in " + file, x);
    }

    return metaData;
}
 
開發者ID:sindremehus,項目名稱:subsonic,代碼行數:80,代碼來源:FFmpegParser.java


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