2012-02-23 9 views

答えて

0

輸入java.io.は、*それを追加されますされていません。

パブリッククラスWriteFileExample {

のpublic static無効メイン(文字列[] args){

String strFilePath = "d:/FileIO.txt"; 

try 
{ 
    FileOutputStream fos = new FileOutputStream(strFilePath); 
    String strContent = "Write File using Java FileOutputStream example !"; 

    /* 
    * To write byte array to a file, use 
    * void write(byte[] bArray) method of Java FileOutputStream class. 
    * 
    * This method writes given byte array to a file. 
    */ 

    fos.write(strContent.getBytes()); 

    /* 
    * Close FileOutputStream using, 
    * void close() method of Java FileOutputStream class. 
    * 
    */ 

    fos.close(); 

} 
catch(FileNotFoundException ex) 
{ 
    System.out.println("FileNotFoundException : " + ex); 
} 
catch(IOException ioe) 
{ 
    System.out.println("IOException : " + ioe); 
} 

}}

+0

私はOPがシリアル化された文字列オブジェクトではなく、文字列のバイトを保存したいと思っています。 – Jeremy

+0

Thanx pravinしかし、これらの方法を使って、私はそのファイルの場所を取得できません。私はそのファイルを同じパッケージに入れました。 – Pranali

+0

私の答えを編集しました。 – Java

関連する問題