/** * @since 1.568 */ protected final void createEmptyChangeLog(@Nonnull File changelogFile, @Nonnull TaskListener listener, @Nonnull String rootTag) throws IOException { try (FileWriter w = new FileWriter(changelogFile)) { w.write("<"+rootTag +"/>"); } }
public void saveToFile(String json){ try { File file = new File("beakerx_inspect.json"); FileWriter fileWriter = new FileWriter(file); fileWriter.write(json); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
@SuppressWarnings("DefaultCharset") public static void writeFileOrThrow(File file, CharSequence content) throws IOException { FileWriter writer = new FileWriter(file, false); try { writer.write(content.toString()); } finally { writer.close(); } }
/** * On Windows, jenkins.war is locked, so we place a new version under a special name, * which is picked up by the service wrapper upon restart. */ @Override public void rewriteHudsonWar(File by) throws IOException { File dest = getHudsonWar(); // this should be impossible given the canRewriteHudsonWar method, // but let's be defensive if(dest==null) throw new IOException("jenkins.war location is not known."); // backing up the old jenkins.war before its lost due to upgrading // unless we are trying to rewrite jenkins.war by a backup itself File bak = new File(dest.getPath() + ".bak"); if (!by.equals(bak)) FileUtils.copyFile(dest, bak); String baseName = dest.getName(); baseName = baseName.substring(0,baseName.indexOf('.')); File baseDir = getBaseDir(); File copyFiles = new File(baseDir,baseName+".copies"); try (FileWriter w = new FileWriter(copyFiles, true)) { w.write(by.getAbsolutePath() + '>' + getHudsonWar().getAbsolutePath() + '\n'); } }
public static void writeFile(File file, String text, boolean append) throws IOException { if (file == null || text == null) { throw new IllegalArgumentException(); } if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) { throw new IOException("Could not create parent directory"); } if (!file.exists() && !file.createNewFile()) { throw new IOException("Could not create file"); } FileWriter writer = null; try { writer = new FileWriter(file, append); writer.write(text); } finally { close(writer); } }
private void writeTestPayload(final FileWriter fw1, final FileWriterWithEncoding fw2) throws IOException { assertTrue(file1.exists()); assertTrue(file2.exists()); fw1.write(textContent); fw2.write(textContent); fw1.write(65); fw2.write(65); fw1.write(anotherTestContent); fw2.write(anotherTestContent); fw1.write(anotherTestContent, 1, 2); fw2.write(anotherTestContent, 1, 2); fw1.write("CAFE", 1, 2); fw2.write("CAFE", 1, 2); fw1.flush(); fw2.flush(); }
/** * 覆盖本地 canal.properties * * @param content 远程配置内容文本 */ private void overrideLocalCanalConfig(String content) { try (FileWriter writer = new FileWriter(getConfPath() + "canal.properties")) { writer.write(content); writer.flush(); } catch (Exception e) { logger.error(e.getMessage(), e); } }
/** Writes silence to the transcript file. */ private void writeSilenceToTranscript() { try { float start = getSeconds(totalBytes); totalBytes += silenceFileLength; float end = getSeconds(totalBytes); transcript.write(context + " 1 " + GAP_LABEL + ' ' + start + ' ' + end + " \n"); transcript.flush(); } catch (IOException ioe) { ioe.printStackTrace(); } }
public void saveToFile(String json){ try { File file = new File("beakerx_inspect.json"); FileWriter fileWriter = new FileWriter(file); fileWriter.write(json); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
private static File writeSourceFile(File root, String name, String source) throws IOException { File sourceFile = new File(root, name); sourceFile.getParentFile().mkdirs(); try (FileWriter writer = new FileWriter(sourceFile)) { writer.write(source); } return sourceFile; }
/** * Writes the given text to the file; either in append mode or replace mode depending * the append flag */ public static void write(File file, String text, boolean append) throws IOException { FileWriter writer = new FileWriter(file, append); try { writer.write(text); } finally { writer.close(); } }
private void writeFile(File newFile, String content) throws IOException { try (FileWriter bw = new FileWriter(newFile)) { bw.write(content); } System.out.println("Wrote " + newFile); } }
/** * 覆盖本地application.yml文件 * * @param content 文件内容 */ private void overrideLocalCanalConfig(String content) { try (FileWriter writer = new FileWriter(getConfPath() + "application.yml")) { writer.write(content); writer.flush(); } catch (Exception e) { logger.error(e.getMessage(), e); } }
private void createDashboardConfigFile() throws IOException { try (FileWriter fw = createOrGetFile(webDir, "config")) { fw.write(createConfigJson(DashboardConfiguration.from(webRefreshIntervalMillis, ZonedDateTime.now()))); fw.flush(); } catch (IOException ioe) { LOG.error("Failed to write config file."); throw ioe; } }
public void saveToFile(String json){ try { File file = new File("beakerx_inspect.json"); FileWriter fileWriter = new FileWriter(file); fileWriter.write(json); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
@Test void databaseThatRequireRecoveryIsNotDumpable() throws IOException { File logFile = new File( databaseDirectory.toFile(), TransactionLogFiles.DEFAULT_NAME + ".0" ); try ( FileWriter fileWriter = new FileWriter( logFile ) ) { fileWriter.write( "brb" ); } CommandFailed commandFailed = assertThrows( CommandFailed.class, () -> execute( "foo.db" ) ); assertThat( commandFailed.getMessage(), startsWith( "Active logical log detected, this might be a source of inconsistencies." ) ); }
private void writeToFile(String result) throws IOException { FileWriter writer = null; try { writer = new FileWriter(outputFile); writer.write(result); } finally { if (writer != null) { writer.close(); } } } }
/** Append some lines to a file */ private void write(final File file, final String... lines) throws Exception { try (FileWriter writer = new FileWriter(file, true)) { for (final String line : lines) { writer.write(line + "\n"); } } }
@Override protected void downloadFileImpl(Path remotePath, Path localPath) throws BackupRestoreException { AbstractBackupPath path = pathProvider.get(); path.parseRemote(remotePath.toString()); if (path.getType() == AbstractBackupPath.BackupFileType.META) { // List all files and generate the file try (FileWriter fr = new FileWriter(localPath.toFile())) { JSONArray jsonObj = new JSONArray(); for (AbstractBackupPath filePath : flist) { if (filePath.type == AbstractBackupPath.BackupFileType.SNAP && filePath.time.equals(path.time)) { jsonObj.add(filePath.getRemotePath()); } } fr.write(jsonObj.toJSONString()); fr.flush(); } catch (IOException io) { throw new BackupRestoreException(io.getMessage(), io); } } downloadedFiles.add(remotePath.toString()); }