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


Java MathRuntimeException.createEOFException方法代码示例

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


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

示例1: load

import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
 * Computes the empirical distribution using data read from a URL.
 * @param url  url of the input file
 *
 * @throws IOException if an IO error occurs
 */
public void load(URL url) throws IOException {
    BufferedReader in =
        new BufferedReader(new InputStreamReader(url.openStream()));
    try {
        DataAdapter da = new StreamDataAdapter(in);
        da.computeStats();
        if (sampleStats.getN() == 0) {
            throw MathRuntimeException.createEOFException("URL {0} contains no data",
                                                          url);
        }
        in = new BufferedReader(new InputStreamReader(url.openStream()));
        fillBinStats(in);
        loaded = true;
    } finally {
       try {
           in.close();
       } catch (IOException ex) {
           // ignore
       }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:28,代码来源:EmpiricalDistributionImpl.java

示例2: load

import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
 * Computes the empirical distribution using data read from a URL.
 * @param url  url of the input file
 *
 * @throws IOException if an IO error occurs
 * @throws NullArgumentException if url is null
 */
public void load(URL url) throws IOException, NullArgumentException {
    MathUtils.checkNotNull(url);
    BufferedReader in =
        new BufferedReader(new InputStreamReader(url.openStream()));
    try {
        DataAdapter da = new StreamDataAdapter(in);
        da.computeStats();
        if (sampleStats.getN() == 0) {
            throw MathRuntimeException.createEOFException(LocalizedFormats.URL_CONTAINS_NO_DATA,
                                                          url);
        }
        in = new BufferedReader(new InputStreamReader(url.openStream()));
        fillBinStats(in);
        loaded = true;
    } finally {
       try {
           in.close();
       } catch (IOException ex) {
           // ignore
       }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:30,代码来源:EmpiricalDistributionImpl.java

示例3: load

import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
 * Computes the empirical distribution using data read from a URL.
 * @param url  url of the input file
 * 
 * @throws IOException if an IO error occurs
 */
public void load(URL url) throws IOException {
    BufferedReader in =
        new BufferedReader(new InputStreamReader(url.openStream()));
    try {
        DataAdapter da = new StreamDataAdapter(in);
        try {
            da.computeStats();
        } catch (IOException ioe) {
            // don't wrap exceptions which are already IOException
            throw ioe;
        } catch (RuntimeException rte) {
            // don't wrap RuntimeExceptions
            throw rte;
        } catch (Exception e) {
            throw MathRuntimeException.createIOException(e);
        }
        if (sampleStats.getN() == 0) {
            throw MathRuntimeException.createEOFException("URL {0} contains no data",
                                                          url);
        }
        in = new BufferedReader(new InputStreamReader(url.openStream()));
        fillBinStats(in);
        loaded = true;
    } finally {
       try {
           in.close();
       } catch (IOException ex) {
           // ignore
       }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:38,代码来源:EmpiricalDistributionImpl.java

示例4: getNextReplay

import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
 * 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 NumberFormatException if an invalid numeric string is
 *   encountered in the file
 */
private double getNextReplay() throws IOException {
    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 MathRuntimeException.createEOFException("URL {0} contains no data",
                                                          valuesFileURL);
        }
    }
    return Double.valueOf(str).doubleValue();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:ValueServer.java

示例5: getNextReplay

import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
 * 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 NumberFormatException if an invalid numeric string is
 *   encountered in the file
 */
private double getNextReplay() throws IOException {
    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 MathRuntimeException.createEOFException(LocalizedFormats.URL_CONTAINS_NO_DATA,
                                                          valuesFileURL);
        }
    }
    return Double.valueOf(str).doubleValue();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:ValueServer.java


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