115116117118119120121122
{ Files.delete(file.toPath()); } catch (IOException e) { throw new FSWriteError(e, file); } }
192193194195196197198199200201202
{ file.getChannel().truncate(size); } catch (IOException e) { throw new FSWriteError(e, path); } finally { closeQuietly(file); }
298299300301302303304305
public static void createDirectory(File directory) { if (!directory.exists()) { if (!directory.mkdirs()) throw new FSWriteError(new IOException("Failed to mkdirs " + directory), directory); } }
662663664665666667668669670
if (!dir.isDirectory()) throw new AssertionError(String.format("Invalid directory path %s: path exists but is not a directory", dir)); } else if (!dir.mkdirs() && !(dir.exists() && dir.isDirectory())) { throw new FSWriteError(new IOException("Unable to create directory " + dir), dir); } return dir; }
221222223224225226227228229230231
{ cacheLoader.serialize(key, writer.stream); } catch (IOException e) { throw new FSWriteError(e, writer.getPath()); } keysWritten++; } }
163164165166167168169170171172173
os = new BufferedOutputStream(new FileOutputStream(file, true)); os.write(toString().getBytes()); } catch (IOException e) { throw new FSWriteError(e, file); } finally { FileUtils.closeQuietly(os); }
127128129130131132133134
needsSync = true; } catch (IOException e) { throw new FSWriteError(e, logFile); } }
246247248249250251252253254255
{ buffer.force(); } catch (Exception e) // MappedByteBuffer.force() does not declare IOException but can actually throw it { throw new FSWriteError(e, getPath()); } needsSync = false; } }
292293294295296297298299
logFileAccessor.close(); closed = true; } catch (IOException e) { throw new FSWriteError(e, getPath()); } }
605606607608609610611612613614615
g.writeEndObject(); // write global object g.close(); } catch (IOException e) { throw new FSWriteError(e, tmpFile); } if (oldFile.exists() && manifestFile.exists()) FileUtils.deleteWithConfirm(oldFile);