1 package org.codehaus.plexus.util.io;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.File;
20 import java.io.IOException;
21 import java.io.OutputStreamWriter;
22 import java.io.StringWriter;
23 import java.nio.charset.Charset;
24 import java.nio.file.Files;
25 import java.nio.file.Path;
26 import java.util.Arrays;
27 import java.util.Objects;
28
29
30
31
32
33 public class CachingWriter extends OutputStreamWriter
34 {
35 private final CachingOutputStream cos;
36
37 public CachingWriter( File path, Charset charset ) throws IOException
38 {
39 this( Objects.requireNonNull( path ).toPath(), charset );
40 }
41
42 public CachingWriter( Path path, Charset charset ) throws IOException
43 {
44 this( path, charset, 32 * 1024 );
45 }
46
47 public CachingWriter( Path path, Charset charset, int bufferSize ) throws IOException
48 {
49 this( new CachingOutputStream( path, bufferSize ), charset );
50 }
51
52 private CachingWriter( CachingOutputStream outputStream, Charset charset ) throws IOException
53 {
54 super( outputStream, charset );
55 this.cos = outputStream;
56 }
57
58 public boolean isModified()
59 {
60 return cos.isModified();
61 }
62 }