List of usage examples for java.nio.file StandardOpenOption SYNC
StandardOpenOption SYNC
To view the source code for java.nio.file StandardOpenOption SYNC.
Click Source Link
From source file:divconq.util.IOUtil.java
public static OperationResult saveEntireFile(Path dest, String content) { OperationResult or = new OperationResult(); try {/*from w ww . ja va2 s . co m*/ Files.createDirectories(dest.getParent()); Files.write(dest, Utf8Encoder.encode(content), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE, StandardOpenOption.SYNC); } catch (Exception x) { or.error(1, "Error saving file contents: " + x); } return or; }
From source file:divconq.util.IOUtil.java
public static boolean saveEntireFile2(Path dest, String content) { try {/*from ww w.jav a 2 s . c om*/ Files.createDirectories(dest.getParent()); Files.write(dest, Utf8Encoder.encode(content), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE, StandardOpenOption.SYNC); } catch (Exception x) { return false; } return true; }
From source file:divconq.util.IOUtil.java
public static boolean saveEntireFile2(Path dest, Memory content) { try {//from w ww.jav a 2 s .c o m Files.createDirectories(dest.getParent()); Files.write(dest, content.toArray(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE, StandardOpenOption.SYNC); } catch (Exception x) { return false; } return true; }
From source file:org.jboss.pull.player.LabelProcessor.java
/** * Processes the pull requests {@link #add(org.jboss.dmr.ModelNode) added}. * <p/>// w ww. j a va2 s . co m * This should normally only be invoked once as it makes API calls to GitHub. */ void process() { try { // Get all the open issues to lessen the hits to the API final ModelNode openIssues = getIssues(); // Process each issue in the model for (Property property : issuesModel.asPropertyList()) { final ModelNode value = property.getValue(); // Get the PR url final String prUrl = value.get("pull_request_url").asString(); if (openIssues.hasDefined(prUrl)) { final ModelNode openIssue = openIssues.get(prUrl); // Get the current labels final List<String> currentLabels = getLabels(openIssue); // If no labels are present, we can delete the issue if (currentLabels.isEmpty()) { issuesModel.remove(property.getName()); } else { boolean changeRequired = false; // Process the labels only requiring a change if the label was defined in the configuration final List<String> newLabels = new ArrayList<>(); for (String label : currentLabels) { if (labels.isRemovable(label)) { final String newLabel = labels.getReplacement(label); if (newLabel != null) { newLabels.add(newLabel); } changeRequired = true; } else { newLabels.add(label); } } // Check that the PR has been changed and a change is required if (changeRequired && value.hasDefined("new-sha")) { final String issueUrl = value.get("issue_url").asString(); // Set the new labels setLabels(issueUrl, newLabels); // Node needs to be removed issuesModel.remove(property.getName()); } else if (!changeRequired) { // No change in labels has been required, remove the issue issuesModel.remove(property.getName()); } } } else { // The issue/PR may be closed, we can just delete it issuesModel.remove(property.getName()); } } // Write the issues out to a file try (final PrintWriter writer = new PrintWriter(Files.newBufferedWriter(path, StandardCharsets.UTF_8, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.SYNC, StandardOpenOption.CREATE))) { issuesModel.writeJSONString(writer, false); } } catch (IOException e) { e.printStackTrace(err); } }
From source file:org.apache.druid.segment.loading.LocalDataSegmentPusher.java
private DataSegment createDescriptorFile(DataSegment segment, File dest) throws IOException { log.info("Creating descriptor file at[%s]", dest); // Avoid using Guava in DataSegmentPushers because they might be used with very diverse Guava versions in // runtime, and because Guava deletes methods over time, that causes incompatibilities. Files.write(dest.toPath(), jsonMapper.writeValueAsBytes(segment), StandardOpenOption.CREATE, StandardOpenOption.SYNC); return segment; }
From source file:org.neo4j.io.pagecache.PageCacheTest.java
@Test(timeout = SEMI_LONG_TIMEOUT_MILLIS) public void mustThrowOnUnsupportedOpenOptions() throws Exception { getPageCache(fs, maxPages, pageCachePageSize, PageCacheTracer.NULL); verifyMappingWithOpenOptionThrows(StandardOpenOption.CREATE_NEW); verifyMappingWithOpenOptionThrows(StandardOpenOption.SYNC); verifyMappingWithOpenOptionThrows(StandardOpenOption.DSYNC); verifyMappingWithOpenOptionThrows(new OpenOption() { @Override/*from w w w .j av a 2s . co m*/ public String toString() { return "NonStandardOpenOption"; } }); }