225 val stream = make_stream(new FileOutputStream(file)) |
225 val stream = make_stream(new FileOutputStream(file)) |
226 val writer = new BufferedWriter(new OutputStreamWriter(stream, UTF8.charset)) |
226 val writer = new BufferedWriter(new OutputStreamWriter(stream, UTF8.charset)) |
227 try { writer.append(text) } finally { writer.close } |
227 try { writer.append(text) } finally { writer.close } |
228 } |
228 } |
229 |
229 |
230 def write(file: JFile, text: CharSequence): Unit = write_file(file, text, (s) => s) |
230 def write(file: JFile, text: CharSequence): Unit = write_file(file, text, s => s) |
231 def write(path: Path, text: CharSequence): Unit = write(path.file, text) |
231 def write(path: Path, text: CharSequence): Unit = write(path.file, text) |
232 |
232 |
233 def write_gzip(file: JFile, text: CharSequence): Unit = |
233 def write_gzip(file: JFile, text: CharSequence): Unit = |
234 write_file(file, text, (s: OutputStream) => new GZIPOutputStream(new BufferedOutputStream(s))) |
234 write_file(file, text, (s: OutputStream) => new GZIPOutputStream(new BufferedOutputStream(s))) |
235 def write_gzip(path: Path, text: CharSequence): Unit = write_gzip(path.file, text) |
235 def write_gzip(path: Path, text: CharSequence): Unit = write_gzip(path.file, text) |
236 |
236 |
237 def write_xz(file: JFile, text: CharSequence, options: XZ.Options): Unit = |
237 def write_xz(file: JFile, text: CharSequence, options: XZ.Options): Unit = |
238 File.write_file(file, text, (s) => new XZOutputStream(new BufferedOutputStream(s), options)) |
238 File.write_file(file, text, s => new XZOutputStream(new BufferedOutputStream(s), options)) |
|
239 def write_xz(file: JFile, text: CharSequence): Unit = write_xz(file, text, XZ.options()) |
239 def write_xz(path: Path, text: CharSequence, options: XZ.Options): Unit = |
240 def write_xz(path: Path, text: CharSequence, options: XZ.Options): Unit = |
240 write_xz(path.file, text, options) |
241 write_xz(path.file, text, options) |
|
242 def write_xz(path: Path, text: CharSequence): Unit = write_xz(path, text, XZ.options()) |
241 |
243 |
242 def write_backup(path: Path, text: CharSequence) |
244 def write_backup(path: Path, text: CharSequence) |
243 { |
245 { |
244 path.file renameTo path.backup.file |
246 path.file renameTo path.backup.file |
245 write(path, text) |
247 write(path, text) |