在windows JRE中运行java程序时出现问题

在windows JRE中运行java程序时出现问题,java,windows,string,unicode,Java,Windows,String,Unicode,你好 我用java写了一个程序。 在程序的一部分中,它从网页中提取一个字符串数字并将其转换为整数。 这在linux中可以正常工作。 在windows中,当我从Netbeans的运行/调试选项运行程序时,它可以正常工作 但是当我在windows和JRE上运行它时,它就不工作了!(它错误地提取了该数字)。 这是代码的一部分: subcatPagesCount=0; subcatPagesCount=Integer.parseInt(cutstring(CM.getResult(),"( صفحه 1

你好
我用java写了一个程序。
在程序的一部分中,它从网页中提取一个字符串数字并将其转换为整数。 这在linux中可以正常工作。 在windows中,当我从Netbeans的运行/调试选项运行程序时,它可以正常工作
但是当我在windows和JRE上运行它时,它就不工作了!(它错误地提取了该数字)。
这是代码的一部分:

subcatPagesCount=0;
subcatPagesCount=Integer.parseInt(cutstring(CM.getResult(),"( صفحه 1 از "," )").trim());
lblPagesCount.setText(""+subcatPagesCount);
“切割字符串”方法是:

private String cutstring(String in,String from,String to){
    int st=in.indexOf(from)+from.length();
    return in.substring(st,in.indexOf(to,st));
}
它抛出:

java.lang.NumberFormatException: For input string: "tml PUBLIC "-//W3C//DTD XHTM
L 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ
e" content="text/html;charset=UTF-8" /><title>کامپیوتر :: کامپیوت
ر و  قطعات - istgah.com </title><meta name="keywords" content=",istgah,ا
یستگاه,نیازمندیها , آگهی , تبلیغات , ایران" /><m
eta name="description" content="┌⌐╪º┘à┘╛█î┘ê╪¬╪▒ :: ┌⌐╪º┘à┘╛█î┘ê╪¬╪▒ ┘ê  ┘é╪╖╪╣╪
º╪¬ - istgah.com" /><base href="http://www.istgah.com/" /><link rel="stylesheet"
 type="text/css" href="layout/templates/istblue/css/firev4.css" /><link rel="sty
lesheet" type="text/css" href="layout/templates/istblue/css/style2.css" /></head
><body>  <div style="width:980px; float:right; " dir="rtl" >    <div style="widt
h:213px; height:89px; float:right; " dir="rtl" >          <a href="http://www.is
tgah.com/" >        <img border="0" alt="istgah.com" width="213" height="39" ali
gn="top" src="layout/blue/hr_top_right.gif" />      <img border="0" alt="istgah.
com" width="187" height="50" align="top" src="layout/blue/hr_top_right2.gif" />
  </a>    <div style="display:none;">       <img border="0" alt="" width="0" hei
ght="0" align="top" src="layout/blue/hr_top_right_back.gif" />    </div>
</div>    <div align="right" style="width:767px; height:39px; float:left; backgr
ound-image:url(layout/blue/hr_top_right_back.gif); " dir="rtl" >
<div style="width:360px; float:right; padding-top:17px; " >               <a hre
f="http://www.istgah.com">╪╡┘?╪¡┘ç ╪º╪╡┘ä┘è</a> |                 <a href="http:
//www.istgah.com/province/">استانها</a> |                  <a href="http:
//www.istgah.com/advertise/">نسخه قديم</a> |              <a href="http:
//www.istgah.com/user/">ثبت‌نام</a> |             <a href="http://www.is
tgah.com/contactus/">تماس باما</a>              </div>          <div ali
gn="left" style="width:90px; float:right; padding-top:17px; " >           <font
color="blue" >  </font>         </div>          <div align="left" style="width:3
00px; float:right; padding-top:17px; " >                        ╪º┘à╪▒┘ê╪▓: ΓǬ┌
å┘ç╪º╪▒╪┤┘å╪¿┘ç╪î █▓█╡ ╪º╪│┘?┘å╪» █▒█│█╕█╣ΓǼ           </div>  </div>    <div a
lign="right" style="width:767px; height:50px; float:left; " dir="rtl" >
<div style="width:260px; float:right; padding-top:20px; " >               <form
action="http://www.istgah.com/search/ " method="get">                   جستج
و:                     <input name="stext" class="inputbox" size="25" />
                <input type="image" src="layout/go.gif" align="top" />
  </form>               </div>          <div style="width:500px; float:right; "
>                 <table border="0" width="500px" cellspacing="0" class="mc" dir
="rtl" >  <tr>    <td>    <a href="http://www.istgah.com/fireview/computer/">

.....

http://www.istgah.com/firekeys/key_3551/" > samsung</a> - <a href="http://www.is
tgah.com/firekeys/key_136241/" > هارد اکسترنال</a> - <a href="http:/
/www.istgah.com/firekeys/key_3066/" > ┘?╪▒┘ê╪┤ ┌⌐╪º┘à┘╛█î┘ê╪¬╪▒</a> - <a href="h
ttp://www.istgah.com/firekeys/key_1535/" > acer</a> - <a href="http://www.istgah
.com/firekeys/key_13206/" > رایتر</a> - <a href="http://www.istgah.com/fire
keys/key_3100/" > ساعت</a> - <a href="http://www.istgah.com/firekeys/key_625
08/" > مودم adsl</a> - <a href="http://www.istgah.com/firekeys/key_3123/" >
ضبط</a> - <a href="http://www.istgah.com/firekeys/key_203/" > موبایل</a
> - <a href="http://www.istgah.com/firekeys/key_1276/" > laptop</a> - <a href="h
ttp://www.istgah.com/firekeys/key_7199/" > msi</a> - <a href="http://www.istgah.
com/firekeys/key_2270/" > monitor</a> - <a href="http://www.istgah.com/firekeys/
key_321385/" > 5200</a> - <a href="http://www.istgah.com/firekeys/key_807/" > cd
</a> - <a href="http://www.istgah.com/firekeys/key_1870/" > ups</a> - <a href="h
ttp://www.istgah.com/firekeys/key_927/" > تلویزیون</a> - <a href="http:/
/www.istgah.com/firekeys/key_2079/" > مادربرد</a> - <a href="http://www.i
stgah.com/firekeys/key_1723/" > sony</a> - <a href="http://www.istgah.com/fireke
ys/key_532/" > بازی</a> - <a href="http://www.istgah.com/firekeys/key_846/"
> cool disk</a> - <a href="http://www.istgah.com/firekeys/key_51650/" > ╪º┘ä ╪│█
î ╪»█î</a> - <a href="http://www.istgah.com/firekeys/key_51/" > ╪»┘ê╪▒╪¿█î┘å ╪»█
î╪¼█î╪¬╪º┘ä</a> - <a href="http://www.istgah.com/firekeys/key_13/" > ┌⌐╪º┘à┘╛█î┘
ê╪¬╪▒</a> - <a href="http://www.istgah.com/firekeys/key_1766/" > ╪¿╪º╪¬╪▒█î</a>
- <a href="http://www.istgah.com/firekeys/key_3454/" > dell</a> - <a href="http:
//www.istgah.com/firekeys/key_12084/" > mp4</a> - <a href="http://www.istgah.com
/firekeys/key_3637/" > ram</a> - <a href="http://www.istgah.com/firekeys/key_381
0/" > کارت کپچر</a> -           <br />      </td></tr>            <tr><t
d align="center" >         <br />          <form action="http://www.istgah.com/s
earch/ " method="get">          <b>جستجوگر هوشمند آگهی‌های
 ایستگاه: </b>           <input name="stext" class="inputbox" size="30" /
>               <input type="image" src="layout/go.gif" align="top" />     </for
m>         <br />         </td></tr>    </table>          <div>         <table w
idth="100%" cellpadding="0" cellspacing="0" class="nls" >               <tr><td
class="ghd" colspan="3" >تازه‌های کامپیوتر :: کامپیوتر
┘ê  ┘é╪╖╪╣╪º╪¬ ( ╪╡┘?╪¡┘ç 1 ╪º╪▓ 84"
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at istgahrobot.doscan$Scan.run(doscan.java:536)
        at java.lang.Thread.run(Unknown Source)
java.lang.NumberFormatException:对于输入字符串:“tml公共”-//W3C//DTD XHTM
L 1.0过渡版本//EN“”http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">کامپیوتر :: کامپیوت
╪▒ ┘ê  ┘é╪╖╪╣╪º╪-istgah.com
|                   |               |                                                                                             ╪º┘à╪▒┘ê╪▓: ΓǬ┌
å┘ç╪º╪▒╪┤┘å╪¿┘ç╪î █▓█╡ ╪º╪│┘?┘å╪» █▒█│█╕█╣ΓǼ                 
جستج
و:                     
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
---

جستجوگر هوشمند آگهی‌های ایستگاه:
╪¬╪º╪▓┘çΓÇî┘ç╪º█î ┌⌐╪º┘à┘╛█î┘ê╪¬╪▒ :: ┌⌐╪º┘à┘╛█î┘ê╪¬╪▒ ┘ê ┘é╪╖╪╣╪º╪¬ ( ╪╡┘?╪¡┘ç 1 ╪º╪▓ 84" 位于java.lang.NumberFormatException.forInputString(未知源) 位于java.lang.Integer.parseInt(未知源) 位于java.lang.Integer.parseInt(未知源) 位于istgahrobot.doscan$Scan.run(doscan.java:536) 位于java.lang.Thread.run(未知源)
有什么问题吗?

谢谢

您可能没有在打开Unicode的情况下运行JRE。请尝试使用
文件运行代码。编码
选项:

-Dfile.encoding=UTF8
或者将设置为
-Dfile.encoding=UTF8


有关更多信息,请参阅。

运行它的结果是什么?它会引发异常“java.lang.NumberFormatException”,这是因为“cutstring”提取了html页面中除该数字以外的部分,因此“parseInt”无法解析它!@Snigger-你的
from
to
参数是什么?你的
中的
是好的度量?@justkt:在这个问题中,
from
,“
to
@justkt-“from”和“to”是两个字符串,我想要的字符串在它们之间“剪弦"提取它们之间的字符串。@Snigger-设置
文件.encoding
选项会改变代码运行的方式,这一事实对我来说意味着其他错误。请检查您的代码是否使用了
InputStreamReader
,其中您没有明确指定字符编码。不支持更改
文件.encoding
并可能引入其他错误r问题: