Example usage for java.util StringTokenizer StringTokenizer

List of usage examples for java.util StringTokenizer StringTokenizer

Introduction

In this page you can find the example usage for java.util StringTokenizer StringTokenizer.

Prototype

public StringTokenizer(String str, String delim) 

Source Link

Document

Constructs a string tokenizer for the specified string.

Usage

From source file:au.edu.jcu.kepler.hydrant.JFreeChartPlot.java

public JFreeChartPlot(PlotterBase plotterBase) {
    _plotterBase = plotterBase;/*from  w w  w. ja va 2  s .  com*/
    _dataset = new XYSeriesCollection();
    _chart = ChartFactory.createXYLineChart(getName(), "", "", _dataset, PlotOrientation.VERTICAL, true, false,
            false);
    String value = plotterBase.legend.getExpression();
    _legend = new ArrayList<String>();
    if ((value != null) && !value.trim().equals("")) {
        StringTokenizer tokenizer = new StringTokenizer(value, ",");
        while (tokenizer.hasMoreTokens()) {
            _legend.add(tokenizer.nextToken().trim());
        }
    }
}

From source file:marytts.tools.install.LicenseRegistry.java

private static void loadLocalLicenses() {
    remote2local = new HashMap<URL, String>();
    File downloadDir = new File(System.getProperty("mary.downloadDir", "."));
    File licenseIndexFile = new File(downloadDir, "license-index.txt");
    if (!licenseIndexFile.canRead()) {
        return; // nothing to load
    }//w ww.j a  v  a2s.c  o  m
    try (BufferedReader br = new BufferedReader(
            new InputStreamReader(new FileInputStream(licenseIndexFile), "UTF-8"))) {
        // Each line in licenseIndexFile is expected to be a pair of local file name (relative to downloadDir) and URL string,
        // separated by a |(pipe) character.

        String line;
        while ((line = br.readLine()) != null) {
            line = line.trim();
            StringTokenizer st = new StringTokenizer(line, "|");
            if (!st.hasMoreTokens()) {
                continue; // skip empty lines
            }
            String localFilename = st.nextToken().trim();
            if (!st.hasMoreTokens()) {
                continue; // skip lines that don't contain a |
            }
            String remoteURLString = st.nextToken().trim();
            File localLicenseFile = new File(downloadDir, localFilename);
            if (!localLicenseFile.canRead()) {
                System.err.println("License index file " + licenseIndexFile.getAbsolutePath()
                        + " refers to license file " + localLicenseFile.getAbsolutePath()
                        + ", but that file cannot be read. Skipping.");
                continue;
            }
            URL remoteURL = new URL(remoteURLString);
            remote2local.put(remoteURL, localFilename);
        }
    } catch (IOException e) {
        System.err.println(
                "Problem reading local license index file " + licenseIndexFile.getAbsolutePath() + ":");
        e.printStackTrace();
    }
}