java.lang.NumberFormatException.toString()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中java.lang.NumberFormatException.toString()方法的一些代码示例,展示了NumberFormatException.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NumberFormatException.toString()方法的具体详情如下:
包路径:java.lang.NumberFormatException
类名称:NumberFormatException
方法名:toString

NumberFormatException.toString介绍

暂无

代码示例

代码示例来源:origin: apache/hive

@Override
public String validate(String value) {
 try {
  float fvalue = Float.parseFloat(value);
  if (fvalue < 0 || fvalue > 1) {
   return "Invalid ratio " + value + ", which should be in between 0 to 1";
  }
 } catch (NumberFormatException e) {
  return e.toString();
 }
 return null;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public byte readByte(String name, byte defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Byte.parseByte(tmpString);
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public double readDouble(String name, double defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Double.parseDouble(tmpString);
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public long readLong(String name, long defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Long.parseLong(tmpString);
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public short readShort(String name, short defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Short.parseShort(tmpString);
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public int readInt(String name, int defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Integer.parseInt(tmpString);
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public float readFloat(String name, float defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    return Float.parseFloat(tmpString);
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: Rukey7/MvpApp

/**
 * 计算图片要显示的高度
 *
 * @param pixel 原始分辨率
 * @param width 要显示的宽度
 * @return
 */
public static int calcPhotoHeight(String pixel, int width) {
  int height = -1;
  int index = pixel.indexOf("*");
  if (index != -1) {
    try {
      int widthPixel = Integer.parseInt(pixel.substring(0, index));
      int heightPixel = Integer.parseInt(pixel.substring(index + 1));
      height = (int) (heightPixel * (width * 1.0f / widthPixel));
    } catch (NumberFormatException e) {
      Logger.e(e.toString());
      return -1;
    }
  }
  return height;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public BitSet readBitSet(String name, BitSet defVal) throws IOException {
  String tmpString = currentElem.getAttribute(name);
  if (tmpString == null || tmpString.length() < 1) return defVal;
  try {
    BitSet set = new BitSet();
    String[] strings = parseTokens(tmpString);
    for (int i = 0; i < strings.length; i++) {
      int isSet = Integer.parseInt(strings[i]);
      if (isSet == 1) {
          set.set(i);
      }
    }
    return set;
  } catch (NumberFormatException nfe) {
    IOException io = new IOException(nfe.toString());
    io.initCause(nfe);
    throw io;
  } catch (DOMException de) {
    IOException io = new IOException(de.toString());
    io.initCause(de);
    throw io;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

IOException io = new IOException(nfe.toString());
io.initCause(nfe);
throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

throw ioe;
} catch (NumberFormatException nfe) {
  IOException io = new IOException(nfe.toString());
  io.initCause(nfe);
  throw io;

代码示例来源:origin: json-iterator/java

public static final double readDoubleSlowPath(final JsonIterator iter) throws IOException {
  try {
    numberChars numberChars = readNumber(iter);
    if (numberChars.charsLength == 0 && iter.whatIsNext() == ValueType.STRING) {
      String possibleInf = iter.readString();
      if ("infinity".equals(possibleInf)) {
        return Double.POSITIVE_INFINITY;
      }
      if ("-infinity".equals(possibleInf)) {
        return Double.NEGATIVE_INFINITY;
      }
      throw iter.reportError("readDoubleSlowPath", "expect number but found string: " + possibleInf);
    }
    return Double.valueOf(new String(numberChars.chars, 0, numberChars.charsLength));
  } catch (NumberFormatException e) {
    throw iter.reportError("readDoubleSlowPath", e.toString());
  }
}

相关文章