当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.URL_CONTAINS_NO_DATA属性代码示例

本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.URL_CONTAINS_NO_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.URL_CONTAINS_NO_DATA属性的具体用法?Java LocalizedFormats.URL_CONTAINS_NO_DATA怎么用?Java LocalizedFormats.URL_CONTAINS_NO_DATA使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math3.exception.util.LocalizedFormats的用法示例。


在下文中一共展示了LocalizedFormats.URL_CONTAINS_NO_DATA属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

/**
 * Computes the empirical distribution using data read from a URL.
 *
 * <p>The input file <i>must</i> be an ASCII text file containing one
 * valid numeric entry per line.</p>
 *
 * @param url url of the input file
 *
 * @throws IOException if an IO error occurs
 * @throws NullArgumentException if url is null
 * @throws ZeroException if URL contains no data
 */
public void load(URL url) throws IOException, NullArgumentException, ZeroException {
    MathUtils.checkNotNull(url);
    Charset charset = Charset.forName(FILE_CHARSET);
    BufferedReader in =
        new BufferedReader(new InputStreamReader(url.openStream(), charset));
    try {
        DataAdapter da = new StreamDataAdapter(in);
        da.computeStats();
        if (sampleStats.getN() == 0) {
            throw new ZeroException(LocalizedFormats.URL_CONTAINS_NO_DATA, url);
        }
        // new adapter for the second pass
        in = new BufferedReader(new InputStreamReader(url.openStream(), charset));
        fillBinStats(new StreamDataAdapter(in));
        loaded = true;
    } finally {
       try {
           in.close();
       } catch (IOException ex) { //NOPMD
           // ignore
       }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:35,代码来源:EmpiricalDistribution.java

示例2: getNextReplay

/**
 * Gets next sequential value from the <code>valuesFileURL</code>.
 * <p>
 * Throws an IOException if the read fails.</p>
 * <p>
 * This method will open the <code>valuesFileURL</code> if there is no
 * replay file open.</p>
 * <p>
 * The <code>valuesFileURL</code> will be closed and reopened to wrap around
 * from EOF to BOF if EOF is encountered. EOFException (which is a kind of
 * IOException) may still be thrown if the <code>valuesFileURL</code> is
 * empty.</p>
 *
 * @return next value from the replay file
 * @throws IOException if there is a problem reading from the file
 * @throws MathIllegalStateException if URL contains no data
 * @throws NumberFormatException if an invalid numeric string is
 *   encountered in the file
 */
private double getNextReplay() throws IOException, MathIllegalStateException {
    String str = null;
    if (filePointer == null) {
        resetReplayFile();
    }
    if ((str = filePointer.readLine()) == null) {
        // we have probably reached end of file, wrap around from EOF to BOF
        closeReplayFile();
        resetReplayFile();
        if ((str = filePointer.readLine()) == null) {
            throw new MathIllegalStateException(LocalizedFormats.URL_CONTAINS_NO_DATA,
                                                valuesFileURL);
        }
    }
    return Double.parseDouble(str);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:35,代码来源:ValueServer.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.URL_CONTAINS_NO_DATA属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。