久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='DI4jM'><style id='DI4jM'><dir id='DI4jM'><q id='DI4jM'></q></dir></style></legend>

<i id='DI4jM'><tr id='DI4jM'><dt id='DI4jM'><q id='DI4jM'><span id='DI4jM'><b id='DI4jM'><form id='DI4jM'><ins id='DI4jM'></ins><ul id='DI4jM'></ul><sub id='DI4jM'></sub></form><legend id='DI4jM'></legend><bdo id='DI4jM'><pre id='DI4jM'><center id='DI4jM'></center></pre></bdo></b><th id='DI4jM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DI4jM'><tfoot id='DI4jM'></tfoot><dl id='DI4jM'><fieldset id='DI4jM'></fieldset></dl></div>

        <bdo id='DI4jM'></bdo><ul id='DI4jM'></ul>

      1. <tfoot id='DI4jM'></tfoot>
      2. <small id='DI4jM'></small><noframes id='DI4jM'>

      3. 用于檢查字符串是否包含*無*異常的數字的 Java

        Java library to check whether a String contains a number *without* exceptions(用于檢查字符串是否包含*無*異常的數字的 Java 庫)

        <i id='kwGhV'><tr id='kwGhV'><dt id='kwGhV'><q id='kwGhV'><span id='kwGhV'><b id='kwGhV'><form id='kwGhV'><ins id='kwGhV'></ins><ul id='kwGhV'></ul><sub id='kwGhV'></sub></form><legend id='kwGhV'></legend><bdo id='kwGhV'><pre id='kwGhV'><center id='kwGhV'></center></pre></bdo></b><th id='kwGhV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='kwGhV'><tfoot id='kwGhV'></tfoot><dl id='kwGhV'><fieldset id='kwGhV'></fieldset></dl></div>

        <small id='kwGhV'></small><noframes id='kwGhV'>

              <bdo id='kwGhV'></bdo><ul id='kwGhV'></ul>
              <tfoot id='kwGhV'></tfoot>
              • <legend id='kwGhV'><style id='kwGhV'><dir id='kwGhV'><q id='kwGhV'></q></dir></style></legend>
                  <tbody id='kwGhV'></tbody>
                • 本文介紹了用于檢查字符串是否包含*無*異常的數字的 Java 庫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如果傳遞的字符串是有效數字(例如123.55e-9"、-333,556"),我正在尋找一種返回布爾值的方法.我不想只想做:

                  I'm looking for a method that returns a boolean if the String it is passed is a valid number (e.g. "123.55e-9", "-333,556"). I don't want to just do:

                  public boolean isANumber(String s) {
                      try { 
                          BigDecimal a = new BigDecimal(s); 
                          return true;
                      } catch (NumberFormatException e) {
                          return false;
                      }
                  }
                  

                  顯然,該函數應該使用狀態機 (DFA) 來解析字符串,以確保無效示例不會欺騙它(例如-21,22.22.2"、33-2").你知道是否存在這樣的圖書館嗎?我真的不想自己寫它,因為這是一個顯而易見的問題,我敢肯定我會重新發明輪子.

                  Clearly, the function should use a state machine (DFA) to parse the string to make sure invalid examples don't fool it (e.g. "-21,22.22.2", "33-2"). Do you know if any such library exists? I don't really want to write it myself as it's such an obvious problem that I'm sure I'd be re-inventing the wheel.

                  謝謝,

                  尼克

                  推薦答案

                  我會避免重新發明這種方法并使用 Apache Commons.如果您使用 Spring、Struts 或許多其他常用的 java 庫,它們通常包含 Apache commons.您將需要 commons-lang.jar 文件.這是 NumberUtils 你想要的:

                  I would avoid re-inventing this method and go with Apache Commons. If your using Spring, Struts or many other commonly used java libraries, they often have Apache commons included. You will want the commons-lang.jar file. Here is the method in NumberUtils you would want:

                  isNumber[1]
                  
                  public static boolean isNumber(java.lang.String str)
                  Checks whether the String a valid Java number.
                  
                  Valid numbers include hexadecimal marked with the 0x qualifier, scientific notation and numbers marked with a type qualifier (e.g. 123L).
                  
                  Null and empty String will return false.
                  
                  Parameters:
                  str - the String to check
                  Returns:
                  true if the string is a correctly formatted number
                  

                  這篇關于用于檢查字符串是否包含*無*異常的數字的 Java 庫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                    <bdo id='svZ33'></bdo><ul id='svZ33'></ul>

                      • <small id='svZ33'></small><noframes id='svZ33'>

                          1. <legend id='svZ33'><style id='svZ33'><dir id='svZ33'><q id='svZ33'></q></dir></style></legend>
                            <tfoot id='svZ33'></tfoot>

                              <tbody id='svZ33'></tbody>
                            <i id='svZ33'><tr id='svZ33'><dt id='svZ33'><q id='svZ33'><span id='svZ33'><b id='svZ33'><form id='svZ33'><ins id='svZ33'></ins><ul id='svZ33'></ul><sub id='svZ33'></sub></form><legend id='svZ33'></legend><bdo id='svZ33'><pre id='svZ33'><center id='svZ33'></center></pre></bdo></b><th id='svZ33'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='svZ33'><tfoot id='svZ33'></tfoot><dl id='svZ33'><fieldset id='svZ33'></fieldset></dl></div>

                            主站蜘蛛池模板: 一级黄色片在线免费观看 | 国产一区二区 | 久久久久久久成人 | 亚洲成人免费网址 | 中文字幕一区二区三区四区五区 | 香蕉视频91| 97影院2| 国产激情在线 | 欧美2区| 久久r免费视频 | 97av视频在线观看 | 精品久久久久久久久久久久 | 日日摸夜夜爽人人添av | com.国产| 毛片在线免费 | 国产高清视频一区 | 日韩三级在线 | 欧美一区久久 | 欧美午夜精品久久久久免费视 | 成人小视频在线观看 | 青青久久久| 人人干人人草 | 久久高清精品 | 中文字幕乱码一区二区三区 | 国产丝袜人妖cd露出 | 天堂一区二区三区 | 国产真实精品久久二三区 | 成人依人| 香蕉婷婷 | 黄色在线免费观看 | 青青草这里只有精品 | 精品国产伦一区二区三区观看体验 | 久色视频在线 | 欧美在线国产精品 | 亚洲综合热 | 国产一区二区三区免费 | 中文字幕一区二区三区四区五区 | 成人免费视频在线观看 | 精国产品一区二区三区四季综 | 亚洲成人一区二区 | 午夜精品久久久久久久久久久久 |