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

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

    1. <small id='YcEua'></small><noframes id='YcEua'>

        Java 在字符串中看不到空格

        Java doesn#39;t see space in string(Java 在字符串中看不到空格)
          <bdo id='f7xNa'></bdo><ul id='f7xNa'></ul>
            <tbody id='f7xNa'></tbody>

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

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

                  本文介紹了Java 在字符串中看不到空格的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  所以,我正在嘗試解析一些包含多行文本的文本文件.我的工作是瀏覽所有單詞并將它們打印在文件中.

                  So, I'm trying to parse some text file which has multiple lines of text. My job is to go through all words and print them out in file.

                  所以,我閱讀了所有的行,我正在循環(huán)它們并用空格分隔每一行,如下所示:

                  So, I read all lines, I'm looping through them and splitting every line by spaces, like this:

                  line.split("\s+");

                  現(xiàn)在,問題是在某些情況下 Java 看不到兩個(gè)單詞之間的空格...

                  Now, the problem is that in some cases Java does not see space between two words...

                  我也試圖遍歷有空格但 Java 看不到它的字符串,并且 Character.isSpaceChar(char) 返回 true...

                  I was also trying to loop through string which has space but Java doesn't see it, and Character.isSpaceChar(char) returned true...

                  現(xiàn)在我完全糊涂了……

                  代碼如下:

                  public void createMap(String inputPath, String outputPath)
                              throws IOException {
                                  File f = new File(inputPath);
                          FileWriter fw = new FileWriter(outputPath);
                          List<String> lines = Files.readAllLines(f.toPath(),
                                  StandardCharsets.UTF_8);
                          for (String l : lines) {
                              for (String w : l.split("\s+")) {
                                  if (isNotRubbish(w.trim())) {
                                      fw.write(w.trim() + "
                  ");
                                  }
                              }
                          }
                          fw.close();
                      }
                  private boolean isNotRubbish(String w) {
                          Pattern p = Pattern.compile("@?\p{L}+",
                                  Pattern.UNICODE_CHARACTER_CLASS);
                          Matcher m = p.matcher(w);
                          return m.matches();
                      }
                  

                  推薦答案

                  我懷疑你的文本字符中有類似于 non-breakable-space 不是空白,因此無法通過 \s 進(jìn)行匹配.

                  I suspect that you have in your text character which is similar to non-breakable-space which is not white space so it can't be matched via \s.

                  在這種情況下,請(qǐng)嘗試使用 p{Zs} 而不是 s.

                  In that case try to use p{Zs} instead of s.

                  如 http://www.regular-expressions.info/unicode.html 中所述

                  p{Zs} 將匹配任何類型的空格字符

                  p{Zs} will match any kind of space character

                  順便說一句,如果您還想包含除空格之外的其他分隔符,例如制表符 或換行符 您可以組合p{Zs}s 類似 [p{Zs}s]

                  BTW if you would also like to include other separators than spaces like tabulators or line breaks you can combine p{Zs} with s like [p{Zs}s]

                  這篇關(guān)于Java 在字符串中看不到空格的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯(cuò)誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數(shù)的三元表達(dá)式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲(chǔ)出現(xiàn)的每個(gè)字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉(zhuǎn)換 char 原語?)
                    <bdo id='Flmy0'></bdo><ul id='Flmy0'></ul>
                  • <i id='Flmy0'><tr id='Flmy0'><dt id='Flmy0'><q id='Flmy0'><span id='Flmy0'><b id='Flmy0'><form id='Flmy0'><ins id='Flmy0'></ins><ul id='Flmy0'></ul><sub id='Flmy0'></sub></form><legend id='Flmy0'></legend><bdo id='Flmy0'><pre id='Flmy0'><center id='Flmy0'></center></pre></bdo></b><th id='Flmy0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Flmy0'><tfoot id='Flmy0'></tfoot><dl id='Flmy0'><fieldset id='Flmy0'></fieldset></dl></div>
                  • <tfoot id='Flmy0'></tfoot>

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

                          <tbody id='Flmy0'></tbody>

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

                            主站蜘蛛池模板: av网站免费 | 欧美性吧 | 天天操天天射综合 | 91久久精品一区二区二区 | 99久久精品免费看国产四区 | 欧美一区二区在线播放 | 在线观看视频亚洲 | 成人av网站在线观看 | 看羞羞视频| av片网站 | 毛片免费视频 | а√中文在线8 | h肉视频| 久久久999免费视频 999久久久久久久久6666 | 综合二区 | 欧美成人一区二免费视频软件 | 91免费版在线观看 | 日韩欧美日韩在线 | 国产免费福利小视频 | av网站在线播放 | 精品国产乱码久久久久久图片 | 羞羞的视频在线观看 | 一级黄色av电影 | 成人深夜福利网站 | 天堂在线一区 | 日韩成人在线观看 | 久久国内 | 欧产日产国产精品视频 | 成人在线日韩 | 欧区一欧区二欧区三免费 | 久久久久久久久久久久久九 | 91电影| 日本一区高清 | 国产高清视频 | 亚洲第1页 | 国产电影一区二区三区爱妃记 | 亚洲日本免费 | 国产伦精品一区二区三区在线 | 久久久精品 | 天天色天天| 欧美老妇交乱视频 |