2009-07-08 8 views
0

はありません ':' このコードの断片を実行しようとしていたときに、URL例外で ...はIllegalArgumentException ...ない ':' URL例外で

FileConnection conn; 

try{ 
    conn =(FileConnection)Connector.open("/NewFile.xml"); 
    if(!conn.exists()) 
     conn.create(); 
    _screen.add(new RichTextField("Connection Established...")); 
    _screen.add(new SeparatorField()); 

} catch(IOException ioe) { 
     _screen.add(new RichTextField(ioe.getMessage())); 
} 

/NEWFILEをその例外を取得しています。 /// NEWFILE:あなたは

ファイルのようなパスを記述する必要が

+0

ファイルのパスまたはURLへとコネクタ? – skaffman

+0

私はこれが薄くなるhttp://developers.sun.com/mobility/apis/articles/fileconnection/ –

+1

J2ME!丘のために実行してください! – skaffman

答えて

0

でxmlファイルでありますその後の.xml/

try{ 
conn =(FileConnection)Connector.open("file:///NewFile.xml/"); 
if(!conn.exists()) 
    conn.create(); 
_screen.add(new RichTextField("Connection Established...")); 
_screen.add(new SeparatorField()); 

} 
catch(IOException ioe) 
{ 
    _screen.add(new RichTextField(ioe.getMessage())); 
} 

Getting Started with fileconnection

5

...:XMLは、ファイルアクセスURLが "//ファイル" で始まる、私のプロジェクト

+0

、またはもっと便利な場合は、java.io.Fileオブジェクトを作成し、その上でtoUrl()を呼び出します。これは、あいまいなファイルのURL構文で悩む必要がなくなります。 – skaffman

+0

はい、絶対URLは必要ですが、相対URLは必要ありません。 –

1

使用ファイル、およびtoUrl()

1

あなたはファイル接続は必要ありませんが、直接入力ストリームを使用してjarファイルからデータを読み込むことができます。

Class.getClass().getResourceAsStream("/NewFile.xml"); 
-1

接頭辞 "のhttp://" を追加しFileConnectiは何ですか

関連する問題