String data="this we want append in that file";
byte[] getbyte = data.getBytes();
outputstream.write(getbyte);
outputstream.flush();
通過使用這些代碼I M試圖寫在particlar文件中的數據,但數據不會被添加它將該文件使用的OutputStream
數據添加到特定的文件String data="this we want append in that file";
byte[] getbyte = data.getBytes();
outputstream.write(getbyte);
outputstream.flush();
通過使用這些代碼I M試圖寫在particlar文件中的數據,但數據不會被添加它將該文件使用的OutputStream
數據添加到特定的文件進口java.io. *;
公共類WriteFileExample {
公共靜態無效的主要(字串[] 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);
}
}}
如何創建'outputstream'? – Jeremy 2012-02-23 05:24:00