2012-10-19 40 views
0

我已经更新了我的脚本,以下提到的内容,但我仍然得到相同的语法错误...任何建议?正确地从服务器读取文本

<fx:Script> 
<![CDATA[ 
    try { 
     URL url = new URL("http://www.rwolfc.com/App/TRY.txt"){; 
     BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); 
     String str; 
     while ((str = in.readLine()) != null) { 
     } 
     in.close(); 
    } catch (MalformedURLException e) { 
    } catch (IOException e) { 
    } 
]]> 


    </fx:Script>    

但是当我使用这个我得到了柔性以下错误:

1071: Syntax error: expected a definition keyword (such as function) after attribute String, not str. 
1073: Syntax error: expecting a catch or finally clause. 
1084: Syntax error: expecting rightbrace before leftbrace. 

帮助!! ?? !!

+1

你的代码几乎是语法正确的Java代码,但你这个标记为' flex4.6',你提到'fx:Script'。我想你可能会对你正在使用的编程语言感到困惑。 –

回答

1

在以下行中你是不是将结果分配给一个变量

URL = new URL("http://www.rwolfc.com/App/TRY.txt"); 

应该

URL url = new URL("http://www.rwolfc.com/App/TRY.txt"); 
+0

嗨。我也试过,我仍然收到相同的语法错误? – user1646878