/** * Create an Internet shortcut * * @param name name of the shortcut * @param where location of the shortcut * @param target URL * @param icon URL (ex. http://www.server.com/favicon.ico) */ public static void createInternetShortcut(String name, String where, String target, String icon) { try (FileWriter fw = new FileWriter(where)) { fw.write("[InternetShortcut]\n"); fw.write("URL=" + target + '\n'); if (!icon.isEmpty()) fw.write("IconFile=" + icon + '\n'); } catch (IOException iox) { /**/ } }
/** * Write a single string to the assembler source file. * * @param String s The string to be written */ private static void emit(String s) { try { out.write(s, 0, s.length()); } catch (IOException e) { throw new Error(e); } }
private static void writeCommandFile() { LineNumberReader inputReader = getInputReader(); String output = generateCommands(inputReader); FileWriter commandOutput = getCommandWriter(); try { commandOutput.write(output, 0, output.length()); commandOutput.close(); } catch (IOException e) { throw new RuntimeException("Could not output generated commands"); } System.out.println("Goals generated"); }
/** * This function performs the testing for a particular format indicated by the format string. It * subsequently sets up appropriate input and output streams for the format test, performs the * test, and the compares the test results to the goals. If the goals differ from the actual * results the test fails. * * @return false if any tests fail. */ private static boolean execute() { LineNumberReader commandReader = getCommands(); String output = performTest(commandReader); if (output == null) { // no errors return true; } else { FileWriter diffsOutput = getDiffsOutputWriter(); try { diffsOutput.write(output, 0, output.length()); diffsOutput.close(); } catch (IOException e) { throw new RuntimeException("Could not output generated diffs"); } return false; } }
private void writeJsonJobs(ApplicationInfo appInfo, List<CIJob> jobs, String status) throws PhrescoException { try { if (jobs == null) { return; } Gson gson = new Gson(); List<CIJob> existingJobs = getJobs(appInfo); if (CI_CREATE_NEW_JOBS.equals(status) || existingJobs == null) { existingJobs = new ArrayList<CIJob>(); } existingJobs.addAll(jobs); FileWriter writer = null; File ciJobFile = new File(getCIJobPath(appInfo)); String jobJson = gson.toJson(existingJobs); writer = new FileWriter(ciJobFile); writer.write(jobJson); writer.flush(); } catch (Exception e) { throw new PhrescoException(e); } }
private boolean adaptExistingJobs(ApplicationInfo appInfo) { try { CIJob existJob = getJob(appInfo); S_LOGGER.debug("Going to get existing jobs to relocate!!!!!"); if (existJob != null) { S_LOGGER.debug("Existing job found " + existJob.getName()); boolean deleteExistJob = deleteCIJobFile(appInfo); Gson gson = new Gson(); List<CIJob> existingJobs = new ArrayList<CIJob>(); existingJobs.addAll(Arrays.asList(existJob)); FileWriter writer = null; File ciJobFile = new File(getCIJobPath(appInfo)); String jobJson = gson.toJson(existingJobs); writer = new FileWriter(ciJobFile); writer.write(jobJson); writer.flush(); S_LOGGER.debug("Existing job moved to new type of project!!"); } return true; } catch (Exception e) { S_LOGGER.debug("It is already adapted !!!!! "); } return false; }