Skip to content

Commit 947b074

Browse files
author
Gary Gregory
committed
Sort members.
1 parent 282b9f9 commit 947b074

1 file changed

Lines changed: 89 additions & 89 deletions

File tree

src/main/java/org/apache/commons/io/output/LockableFileWriter.java

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -59,43 +59,6 @@ public class LockableFileWriter extends Writer {
5959
/** The lock file. */
6060
private final File lockFile;
6161

62-
/**
63-
* Constructs a LockableFileWriter.
64-
* If the file exists, it is overwritten.
65-
*
66-
* @param fileName the file to write to, not null
67-
* @throws NullPointerException if the file is null
68-
* @throws IOException in case of an I/O error
69-
*/
70-
public LockableFileWriter(final String fileName) throws IOException {
71-
this(fileName, false, null);
72-
}
73-
74-
/**
75-
* Constructs a LockableFileWriter.
76-
*
77-
* @param fileName file to write to, not null
78-
* @param append true if content should be appended, false to overwrite
79-
* @throws NullPointerException if the file is null
80-
* @throws IOException in case of an I/O error
81-
*/
82-
public LockableFileWriter(final String fileName, final boolean append) throws IOException {
83-
this(fileName, append, null);
84-
}
85-
86-
/**
87-
* Constructs a LockableFileWriter.
88-
*
89-
* @param fileName the file to write to, not null
90-
* @param append true if content should be appended, false to overwrite
91-
* @param lockDir the directory in which the lock file should be held
92-
* @throws NullPointerException if the file is null
93-
* @throws IOException in case of an I/O error
94-
*/
95-
public LockableFileWriter(final String fileName, final boolean append, final String lockDir) throws IOException {
96-
this(new File(fileName), append, lockDir);
97-
}
98-
9962
/**
10063
* Constructs a LockableFileWriter.
10164
* If the file exists, it is overwritten.
@@ -148,21 +111,6 @@ public LockableFileWriter(final File file, final Charset charset) throws IOExcep
148111
this(file, charset, false, null);
149112
}
150113

151-
/**
152-
* Constructs a LockableFileWriter with a file encoding.
153-
*
154-
* @param file the file to write to, not null
155-
* @param charsetName the name of the requested charset, null means platform default
156-
* @throws NullPointerException if the file is null
157-
* @throws IOException in case of an I/O error
158-
* @throws java.nio.charset.UnsupportedCharsetException
159-
* thrown instead of {@link java.io.UnsupportedEncodingException} in version 2.2 if the encoding is not
160-
* supported.
161-
*/
162-
public LockableFileWriter(final File file, final String charsetName) throws IOException {
163-
this(file, charsetName, false, null);
164-
}
165-
166114
/**
167115
* Constructs a LockableFileWriter with a file encoding.
168116
*
@@ -201,6 +149,21 @@ public LockableFileWriter(File file, final Charset charset, final boolean append
201149
out = initWriter(file, charset, append);
202150
}
203151

152+
/**
153+
* Constructs a LockableFileWriter with a file encoding.
154+
*
155+
* @param file the file to write to, not null
156+
* @param charsetName the name of the requested charset, null means platform default
157+
* @throws NullPointerException if the file is null
158+
* @throws IOException in case of an I/O error
159+
* @throws java.nio.charset.UnsupportedCharsetException
160+
* thrown instead of {@link java.io.UnsupportedEncodingException} in version 2.2 if the encoding is not
161+
* supported.
162+
*/
163+
public LockableFileWriter(final File file, final String charsetName) throws IOException {
164+
this(file, charsetName, false, null);
165+
}
166+
204167
/**
205168
* Constructs a LockableFileWriter with a file encoding.
206169
*
@@ -220,18 +183,53 @@ public LockableFileWriter(final File file, final String charsetName, final boole
220183
}
221184

222185
/**
223-
* Tests that we can write to the lock directory.
186+
* Constructs a LockableFileWriter.
187+
* If the file exists, it is overwritten.
224188
*
225-
* @param lockDir the File representing the lock directory
226-
* @throws IOException if we cannot write to the lock directory
227-
* @throws IOException if we cannot find the lock file
189+
* @param fileName the file to write to, not null
190+
* @throws NullPointerException if the file is null
191+
* @throws IOException in case of an I/O error
228192
*/
229-
private void testLockDir(final File lockDir) throws IOException {
230-
if (!lockDir.exists()) {
231-
throw new IOException("Could not find lockDir: " + lockDir.getAbsolutePath());
232-
}
233-
if (!lockDir.canWrite()) {
234-
throw new IOException("Could not write to lockDir: " + lockDir.getAbsolutePath());
193+
public LockableFileWriter(final String fileName) throws IOException {
194+
this(fileName, false, null);
195+
}
196+
197+
/**
198+
* Constructs a LockableFileWriter.
199+
*
200+
* @param fileName file to write to, not null
201+
* @param append true if content should be appended, false to overwrite
202+
* @throws NullPointerException if the file is null
203+
* @throws IOException in case of an I/O error
204+
*/
205+
public LockableFileWriter(final String fileName, final boolean append) throws IOException {
206+
this(fileName, append, null);
207+
}
208+
209+
/**
210+
* Constructs a LockableFileWriter.
211+
*
212+
* @param fileName the file to write to, not null
213+
* @param append true if content should be appended, false to overwrite
214+
* @param lockDir the directory in which the lock file should be held
215+
* @throws NullPointerException if the file is null
216+
* @throws IOException in case of an I/O error
217+
*/
218+
public LockableFileWriter(final String fileName, final boolean append, final String lockDir) throws IOException {
219+
this(new File(fileName), append, lockDir);
220+
}
221+
222+
/**
223+
* Closes the file writer and deletes the lock file.
224+
*
225+
* @throws IOException if an I/O error occurs.
226+
*/
227+
@Override
228+
public void close() throws IOException {
229+
try {
230+
out.close();
231+
} finally {
232+
FileUtils.delete(lockFile);
235233
}
236234
}
237235

@@ -249,6 +247,15 @@ private void createLock() throws IOException {
249247
}
250248
}
251249

250+
/**
251+
* Flushes the stream.
252+
* @throws IOException if an I/O error occurs.
253+
*/
254+
@Override
255+
public void flush() throws IOException {
256+
out.flush();
257+
}
258+
252259
/**
253260
* Initializes the wrapped file writer.
254261
* Ensure that a cleanup occurs if the writer creation fails.
@@ -274,27 +281,19 @@ private Writer initWriter(final File file, final Charset charset, final boolean
274281
}
275282

276283
/**
277-
* Closes the file writer and deletes the lock file.
284+
* Tests that we can write to the lock directory.
278285
*
279-
* @throws IOException if an I/O error occurs.
286+
* @param lockDir the File representing the lock directory
287+
* @throws IOException if we cannot write to the lock directory
288+
* @throws IOException if we cannot find the lock file
280289
*/
281-
@Override
282-
public void close() throws IOException {
283-
try {
284-
out.close();
285-
} finally {
286-
FileUtils.delete(lockFile);
290+
private void testLockDir(final File lockDir) throws IOException {
291+
if (!lockDir.exists()) {
292+
throw new IOException("Could not find lockDir: " + lockDir.getAbsolutePath());
293+
}
294+
if (!lockDir.canWrite()) {
295+
throw new IOException("Could not write to lockDir: " + lockDir.getAbsolutePath());
287296
}
288-
}
289-
290-
/**
291-
* Writes a character.
292-
* @param c the character to write
293-
* @throws IOException if an I/O error occurs.
294-
*/
295-
@Override
296-
public void write(final int c) throws IOException {
297-
out.write(c);
298297
}
299298

300299
/**
@@ -319,6 +318,16 @@ public void write(final char[] cbuf, final int off, final int len) throws IOExce
319318
out.write(cbuf, off, len);
320319
}
321320

321+
/**
322+
* Writes a character.
323+
* @param c the character to write
324+
* @throws IOException if an I/O error occurs.
325+
*/
326+
@Override
327+
public void write(final int c) throws IOException {
328+
out.write(c);
329+
}
330+
322331
/**
323332
* Writes the characters from a string.
324333
* @param str the string to write
@@ -341,13 +350,4 @@ public void write(final String str, final int off, final int len) throws IOExcep
341350
out.write(str, off, len);
342351
}
343352

344-
/**
345-
* Flushes the stream.
346-
* @throws IOException if an I/O error occurs.
347-
*/
348-
@Override
349-
public void flush() throws IOException {
350-
out.flush();
351-
}
352-
353353
}

0 commit comments

Comments
 (0)