List of usage examples for java.io IOException getMessage
public String getMessage()
From source file:com.netsteadfast.greenstep.util.JReportUtils.java
public static void deploy() throws ServiceException, Exception { logger.info("begin deploy..."); List<TbSysJreport> reports = sysJreportService.findListByParams(null); String reportDeployDirName = Constants.getDeployJasperReportDir() + "/"; File reportDeployDir = new File(reportDeployDirName); try {//w w w . ja v a2 s.c om if (reportDeployDir.exists()) { logger.warn("delete " + reportDeployDirName); FileUtils.forceDelete(reportDeployDir); } logger.warn("mkdir " + reportDeployDirName); FileUtils.forceMkdir(reportDeployDir); for (TbSysJreport report : reports) { deployReport(report); } } catch (IOException e) { e.printStackTrace(); logger.error(e.getMessage().toString()); } reportDeployDir = null; logger.info("end deploy..."); }
From source file:net.grinder.util.LogCompressUtils.java
/** * Decompress the given the {@link InputStream} into the given {@link OutputStream}. * * @param inputStream input stream of the compressed file * @param outputStream file to be written * @param limit the limit of the output *///from www . ja va 2 s . co m public static void decompress(InputStream inputStream, OutputStream outputStream, long limit) { ZipInputStream zipInputStream = null; try { zipInputStream = new ZipInputStream(inputStream); byte[] buffer = new byte[COMPRESS_BUFFER_SIZE]; int count; long total = 0; checkNotNull(zipInputStream.getNextEntry(), "In zip, it should have at least one entry"); do { while ((count = zipInputStream.read(buffer, 0, COMPRESS_BUFFER_SIZE)) != -1) { total += count; if (total >= limit) { break; } outputStream.write(buffer, 0, count); } } while (zipInputStream.getNextEntry() != null); outputStream.flush(); } catch (IOException e) { LOGGER.error("Error occurs while decompressing {}", e.getMessage()); LOGGER.debug("Details : ", e); } finally { IOUtils.closeQuietly(zipInputStream); } }
From source file:classpackage.ChartGalaxy.java
public static XYDataset createDataset() { LabeledXYDataset series = new LabeledXYDataset(); List<String> vetorLinha = new ArrayList<>(); List<List> lista = new ArrayList<>(); try {/* w w w.j av a 2 s.co m*/ FileReader arq = new FileReader("Arquivo.txt"); BufferedReader lerArq = new BufferedReader(arq); String linha = lerArq.readLine(); while (linha != null) { String caracteres = " #@_\\/*|"; String parts[] = linha.split("[" + Pattern.quote(caracteres) + "]"); for (String i : parts) { vetorLinha.add(i); } lista.add(vetorLinha); vetorLinha = new ArrayList<>(); linha = lerArq.readLine(); } for (int i = 0; i < lista.size(); i++) { // for (int j = 0; j < vetorLinha.size(); j++) { double a = Double.parseDouble(lista.get(i).get(0).toString()); double b = Double.parseDouble(lista.get(i).get(1).toString()); String label = lista.get(i).get(2).toString(); //System.out.println(lista.get(i).get(j)); //} series.add(a, b, label); } } catch (IOException e) { System.out.println(e.getMessage()); } return series; }
From source file:iplantappssplitter.IPlantAppsSplitter.java
/** * ReadFile reads the file specified by filename and then returns a string * with the entire contents of the file. * @param filename/* w w w . j ava 2 s . c o m*/ * @return */ public static String ReadFile(String filename) { String Json = null; try { byte[] encoded = Files.readAllBytes(Paths.get(filename)); Json = new String(encoded); } catch (IOException e) { System.err.println(e.getMessage()); System.exit(-1); } return Json; }
From source file:com.apigee.edge.config.utils.ConfigReader.java
/** * API Config//from w w w. ja va2s . co m * [ {apiProduct1}, {apiProduct2}, {apiProduct3} ] */ public static List getAPIConfig(File configFile) throws ParseException, IOException { Logger logger = LoggerFactory.getLogger(ConfigReader.class); JSONParser parser = new JSONParser(); ArrayList out = null; try { BufferedReader bufferedReader = new BufferedReader(new java.io.FileReader(configFile)); JSONArray resourceConfigs = (JSONArray) parser.parse(bufferedReader); if (resourceConfigs == null) return null; out = new ArrayList(); for (Object config : resourceConfigs) { out.add(((JSONObject) config).toJSONString()); } } catch (IOException ie) { logger.info(ie.getMessage()); throw ie; } catch (ParseException pe) { logger.info(pe.getMessage()); throw pe; } return out; }
From source file:com.iblsoft.iwxxm.webservice.Main.java
private static void validateFiles(List<String> files) { Configuration configuration = ConfigManager.getConfiguration(); IwxxmValidator iwxxmValidator = new IwxxmValidator(configuration.getValidationCatalogFile(), configuration.getValidationRulesDir(), configuration.getDefaultIwxxmVersion()); for (String filePath : files) { filePath = filePath.replace("//", "/"); File localFile = new File(filePath); DirectoryScanner scanner = new DirectoryScanner(); if (!localFile.isAbsolute()) { scanner.setBasedir("."); }/*from w w w. j a v a 2 s. c o m*/ scanner.setIncludes(new String[] { filePath }); scanner.scan(); String[] expandedFiles = scanner.getIncludedFiles(); if (expandedFiles.length == 0) { System.out.println("No file matches the pattern " + filePath); } for (String file : expandedFiles) { System.out.print("Validating file " + file + " ... "); try { ValidationResult result = iwxxmValidator.validate( FileUtils.readFileToString(new File(file), StandardCharsets.UTF_8.name()), null); if (result.isValid()) { System.out.println("Validation successful"); } else { System.out.println("Validation failed"); for (ValidationError ve : result.getValidationErrors()) { System.out.println(" " + ve); } } } catch (IOException e) { System.out.println(); System.out.println("Error: " + e.getMessage()); System.exit(1); return; } } } }
From source file:info.magnolia.cms.beans.config.Bootstrapper.java
/** * Repositories appears to be empty and the <code>"magnolia.bootstrap.dir</code> directory is configured in * web.xml. Loops over all the repositories and try to load any xml file found in a subdirectory with the same name * of the repository. For example the <code>config</code> repository will be initialized using all the * <code>*.xml</code> files found in <code>"magnolia.bootstrap.dir</code><strong>/config</strong> directory. * @param bootdirs bootstrap dir// w w w. j a v a 2 s. co m */ protected static void bootstrapRepositories(String[] bootdirs) { if (log.isInfoEnabled()) { log.info("-----------------------------------------------------------------"); //$NON-NLS-1$ log.info("Trying to initialize repositories from:"); for (int i = 0; i < bootdirs.length; i++) { log.info(bootdirs[i]); } log.info("-----------------------------------------------------------------"); //$NON-NLS-1$ } MgnlContext.setInstance(MgnlContext.getSystemContext()); Iterator repositoryNames = ContentRepository.getAllRepositoryNames(); while (repositoryNames.hasNext()) { String repository = (String) repositoryNames.next(); Set xmlfileset = new TreeSet(new Comparator() { // remove file with the same name in different dirs public int compare(Object file1obj, Object file2obj) { File file1 = (File) file1obj; File file2 = (File) file2obj; String fn1 = file1.getParentFile().getName() + '/' + file1.getName(); String fn2 = file2.getParentFile().getName() + '/' + file2.getName(); return fn1.compareTo(fn2); } }); for (int j = 0; j < bootdirs.length; j++) { String bootdir = bootdirs[j]; File xmldir = new File(bootdir, repository); if (!xmldir.exists() || !xmldir.isDirectory()) { continue; } File[] files = xmldir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(DataTransporter.XML) || name.endsWith(DataTransporter.ZIP) || name.endsWith(DataTransporter.GZ); //$NON-NLS-1$ } }); xmlfileset.addAll(Arrays.asList(files)); } if (xmlfileset.isEmpty()) { log.info("No bootstrap files found in directory [{}], skipping...", repository); //$NON-NLS-1$ continue; } log.info("Trying to import content from {} files into repository [{}]", //$NON-NLS-1$ Integer.toString(xmlfileset.size()), repository); File[] files = (File[]) xmlfileset.toArray(new File[xmlfileset.size()]); Arrays.sort(files, new Comparator() { public int compare(Object file1, Object file2) { String name1 = StringUtils.substringBeforeLast(((File) file1).getName(), "."); //$NON-NLS-1$ String name2 = StringUtils.substringBeforeLast(((File) file2).getName(), "."); //$NON-NLS-1$ // a simple way to detect nested nodes return name1.length() - name2.length(); } }); try { for (int k = 0; k < files.length; k++) { File xmlfile = files[k]; DataTransporter.executeBootstrapImport(xmlfile, repository); } } catch (IOException ioe) { log.error(ioe.getMessage(), ioe); } catch (OutOfMemoryError e) { int maxMem = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024); int needed = Math.max(256, maxMem + 128); log.error("Unable to complete bootstrapping: out of memory.\n" //$NON-NLS-1$ + "{} MB were not enough, try to increase the amount of memory available by adding the -Xmx{}m parameter to the server startup script.\n" //$NON-NLS-1$ + "You will need to completely remove the magnolia webapp before trying again", //$NON-NLS-1$ Integer.toString(maxMem), Integer.toString(needed)); break; } log.info("Repository [{}] has been initialized.", repository); //$NON-NLS-1$ } }
From source file:com.project.utilities.Utilities.java
public static void writeToFileViolationListJSON() { String violationJSONList = getRequest(Constants.API_VIOLATIONS); File currentConfig = new File(Constants.EXTERNAL_DIRECTORY + "/" + Constants.FILENAME_VIOLATION_JSON); try {/* w w w. j a va 2s .c om*/ currentConfig.createNewFile(); FileOutputStream fos = new FileOutputStream(currentConfig); fos.write(violationJSONList.getBytes()); fos.close(); } catch (IOException e) { Log.e("ERROR CREATING JSON FILE", e.getMessage().toString()); } }
From source file:com.apigee.edge.config.utils.ConfigReader.java
/** * Example Hierarchy/*from w ww. j a v a 2 s .c om*/ * envConfig.cache.<env>.caches * * Returns List of * [ {cache1}, {cache2}, {cache3} ] */ public static List getEnvConfig(String env, File configFile) throws ParseException, IOException { Logger logger = LoggerFactory.getLogger(ConfigReader.class); JSONParser parser = new JSONParser(); ArrayList out = null; try { BufferedReader bufferedReader = new BufferedReader(new java.io.FileReader(configFile)); JSONArray configs = (JSONArray) parser.parse(bufferedReader); if (configs == null) return null; out = new ArrayList(); for (Object config : configs) { out.add(((JSONObject) config).toJSONString()); } } catch (IOException ie) { logger.info(ie.getMessage()); throw ie; } catch (ParseException pe) { logger.info(pe.getMessage()); throw pe; } return out; }
From source file:de.prozesskraft.pkraft.Clone.java
/** * clone Process mit Daten/* w w w . java 2 s .c o m*/ * returns process-id * @param entity */ public static Process cloneProcess(Process process, Process parentProcess) { // klonen mit data Process clone = null; if (parentProcess == null) { clone = process.cloneWithData(null, null); System.err.println("info: cloning instance: original=" + process.getRootdir() + "/process.pmb, clone=" + clone.getRootdir() + "/process.pmb"); } else { clone = process.cloneWithData(parentProcess.getRootdir() + "/dir4step_" + process.getStepnameOfParent(), parentProcess.getId()); System.err.println("debug: stepname of parentProcess is: " + process.getStepnameOfParent()); System.err.println("debug: process.cloneWithData(" + parentProcess.getRootdir() + "/dir4step_" + process.getStepnameOfParent() + ", " + parentProcess.getId()); System.err.println("info: cloning instance as a child: original=" + process.getRootdir() + "/process.pmb, clone=" + clone.getRootdir() + "/process.pmb"); } // // das original speichern, weil auch hier aenderungen vorhanden sind (zaehler fuer klone) process.setOutfilebinary(process.getInfilebinary()); process.writeBinary(); // den prozess in pradar anmelden durch aufruf des tools: pradar-attend String call2 = ini.get("apps", "pradar-attend") + " -instance " + clone.getRootdir() + "/process.pmb"; System.err.println("info: calling: " + call2); try { java.lang.Process sysproc = Runtime.getRuntime().exec(call2); } catch (IOException e) { System.err.println("error: " + e.getMessage()); } // rueckgabe der id. kann beim klonen von childprozessen verwendet werden return clone; }