2017-09-26 4 views

答えて

1

フラグオプションを使用すると、ファイルの書き込みや上書きに関するさまざまな動作を設定できます。あなたは(これはデフォルト値である)が存在する場合、それはファイルを上書きしますwフラグを渡す場合は、フラグr+を使用している場合、それならば、それだけでファイルを変更します一方、WriteStreamを作成するたとえば

、読み取りと書き込みのためにファイルを実際に開くときに存在します。存在しない場合はエラーが発生します。ここで

はフラグの失われ、そこに説明されています

'r' - Open file for reading. An exception occurs if the file does not exist. 
'r+' - Open file for reading and writing. An exception occurs if the file does not exist. 
'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists). 
'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). 
'a' - Open file for appending. The file is created if it does not exist. 
'a+' - Open file for reading and appending. The file is created if it does not exist.