Lines Matching refs:file

3  * contributor license agreements.  See the NOTICE file distributed with
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
32 * cross thread file lock handling.
35 * that will use a lock file to prevent duplicate writes.
37 * By default, the file will be overwritten, but this may be changed to append.
54 /** The extension for the lock file. */
59 /** The lock file. */
64 * If the file exists, it is overwritten.
66 * @param fileName the file to write to, not null
67 * @throws NullPointerException if the file is null
77 * @param fileName file to write to, not null
79 * @throws NullPointerException if the file is null
89 * @param fileName the file to write to, not null
91 * @param lockDir the directory in which the lock file should be held
92 * @throws NullPointerException if the file is null
101 * If the file exists, it is overwritten.
103 * @param file the file to write to, not null
104 * @throws NullPointerException if the file is null
107 public LockableFileWriter(File file) throws IOException {
108 this(file, false, null);
114 * @param file the file to write to, not null
116 * @throws NullPointerException if the file is null
119 public LockableFileWriter(File file, boolean append) throws IOException {
120 this(file, append, null);
126 * @param file the file to write to, not null
128 * @param lockDir the directory in which the lock file should be held
129 * @throws NullPointerException if the file is null
132 public LockableFileWriter(File file, boolean append, String lockDir) throws IOException {
133 this(file, null, append, lockDir);
137 * Constructs a LockableFileWriter with a file encoding.
139 * @param file the file to write to, not null
141 * @throws NullPointerException if the file is null
144 public LockableFileWriter(File file, String encoding) throws IOException {
145 this(file, encoding, false, null);
149 * Constructs a LockableFileWriter with a file encoding.
151 * @param file the file to write to, not null
154 * @param lockDir the directory in which the lock file should be held
155 * @throws NullPointerException if the file is null
158 public LockableFileWriter(File file, String encoding, boolean append,
161 // init file to create/append
162 file = file.getAbsoluteFile();
163 if (file.getParentFile() != null) {
164 FileUtils.forceMkdir(file.getParentFile());
166 if (file.isDirectory()) {
170 // init lock file
177 lockFile = new File(lockDirFile, file.getName() + LCK);
183 out = initWriter(file, encoding, append);
192 * @throws IOException if we cannot find the lock file
206 * Creates the lock file.
208 * @throws IOException if we cannot create the file
213 throw new IOException("Can't write file, lock " +
221 * Initialise the wrapped file writer.
224 * @param file the file to be accessed
230 private Writer initWriter(File file, String encoding, boolean append) throws IOException {
231 boolean fileExistedAlready = file.exists();
236 writer = new FileWriter(file.getAbsolutePath(), append);
238 stream = new FileOutputStream(file.getAbsolutePath(), append);
246 file.delete();
254 file.delete();
263 * Closes the file writer.