本文整理汇总了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
}
}
}
示例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);
}