List of usage examples for java.io IOException IOException
public IOException(Throwable cause)
From source file:es.us.isa.jdataset.loader.ExcelLoader.java
@Override public DataSet load(InputStream is, String extension) throws IOException { try {//from w ww . j a va2 s . c o m StringBuilder sb = new StringBuilder(); ExcelToCSV excel2CSV = new ExcelToCSV(); excel2CSV.convertExcelToCSV(is, sb); return csvLoader.load(new ReaderInputStream(new StringReader(sb.toString())), extension); } catch (IllegalArgumentException ex) { Logger.getLogger(ExcelLoader.class.getName()).log(Level.SEVERE, null, ex); throw new IOException(ex); } catch (InvalidFormatException ex) { Logger.getLogger(ExcelLoader.class.getName()).log(Level.SEVERE, null, ex); throw new IOException(ex); } }
From source file:org.zodiark.server.test.Writer.java
@Override public AsyncIOWriter writeError(AtmosphereResponse r, int errorCode, String message) throws IOException { error.set(new IOException(message)); return this; }
From source file:de.ingrid.interfaces.csw.tools.IdfUtils.java
/** * Extract the idf document from the given record. Throws an exception * if there is not idf content.//from w w w. j a va 2 s.c om * @param record * @return Document * @throws Exception */ public static Document getIdfDocument(Record record) throws Exception { String content = IdfTool.getIdfDataFromRecord(record); if (content != null) { try { return StringUtils.stringToDocument(content); } catch (Throwable t) { log.error("Error transforming record to DOM: " + content, t); throw new Exception(t); } } else { throw new IOException("Document contains no IDF data."); } }
From source file:com.zotoh.core.util.FileUte.java
/** * @param srcFile//from w w w. j ava 2 s . co m * @param destDir * @param createDestDir * @return * @throws IOException */ public static File moveFileToDir(File srcFile, File destDir, boolean createDestDir) throws IOException { tstObjArg("source-file", srcFile); tstObjArg("dest-dir", destDir); if (!destDir.exists() && createDestDir) { destDir.mkdirs(); } if (!destDir.exists() || !destDir.isDirectory()) { throw new IOException("\"" + destDir + "\" does not exist, or not a directory"); } return moveFile(srcFile, new File(destDir, srcFile.getName())); }
From source file:dk.dma.navnet.messages.TextMessageReader.java
public TextMessageReader(String message) throws IOException { requireNonNull(message);/*from w w w. j av a 2 s.c om*/ JsonFactory jsonF = new JsonFactory(); jp = jsonF.createJsonParser(message); if (jp.nextToken() != JsonToken.START_ARRAY) { throw new IOException("Expected the start of a JSON array, but was '" + jp.getText() + "'"); } }
From source file:gov.nih.nci.cacis.mirth.XSLForMirthFormatter.java
/** * Formats all XSL files for Mirth/*from ww w. jav a 2 s .co m*/ * * @param outputDir - String instance for the output dir * @param xsls - String[] representing the path to the xsl files * @throws IOException - error thrown, if any */ public void formatXSL(String outputDir, String[] xsls) throws IOException { final File opDir = new File(outputDir); if (!opDir.exists() && !opDir.mkdirs()) { throw new IOException("Unable to create the output dir"); } for (int i = 0; i < xsls.length; i++) { formatSingleXSl(opDir, xsls[i]); } }
From source file:edu.iu.daal_kmeans.regroupallgather.KMUtil.java
/** * Generate centroids and upload to the cDir * /*w w w . ja v a2s . c o m*/ * @param numCentroids * @param vectorSize * @param configuration * @param random * @param cenDir * @param fs * @throws IOException */ static void generateCentroids(int numCentroids, int vectorSize, Configuration configuration, Path cenDir, FileSystem fs) throws IOException { Random random = new Random(); double[] data = null; if (fs.exists(cenDir)) fs.delete(cenDir, true); if (!fs.mkdirs(cenDir)) { throw new IOException("Mkdirs failed to create " + cenDir.toString()); } data = new double[numCentroids * vectorSize]; for (int i = 0; i < data.length; i++) { data[i] = random.nextDouble() * 1000; } Path initClustersFile = new Path(cenDir, Constants.CENTROID_FILE_NAME); System.out.println("Generate centroid data." + initClustersFile.toString()); FSDataOutputStream out = fs.create(initClustersFile, true); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out)); for (int i = 0; i < data.length; i++) { if ((i % vectorSize) == (vectorSize - 1)) { bw.write(data[i] + ""); bw.newLine(); } else { bw.write(data[i] + " "); } } bw.flush(); bw.close(); System.out.println("Wrote centroids data to file"); }
From source file:com.enonic.cms.itest.home.HomeDirFactory.java
private void copyFile(final String resource) throws IOException { final String from = "/homeDir/" + resource; final File to = new File(this.homeDir.toFile(), resource); final URL url = getClass().getResource(from); if (url == null) { throw new IOException("Resource [" + from + "] not found"); }/*from w w w.ja v a 2 s . com*/ Files.createParentDirs(to); Files.copy(Resources.newInputStreamSupplier(url), to); }
From source file:com.aliyun.odps.local.common.utils.ArchiveUtils.java
public static void unArchive(File inFile, File outDir) throws IOException { try {//from w w w . ja v a2 s . co m String name = inFile.getName().toLowerCase(); if (name.endsWith(".zip")) { unZip(inFile, outDir); } else if (name.endsWith(".jar")) { unJar(inFile, outDir); } else if (name.endsWith(".tar.gz") || name.endsWith(".tgz")) { unGZip(inFile, outDir); } else if (name.endsWith(".tar")) { unTar(inFile, outDir); } } catch (ArchiveException ex) { throw new IOException(ex); } }
From source file:com.siemens.sw360.fossology.config.FossologySettings.java
private static byte[] loadKeyFile(String keyFilePath) { byte[] fossologyPrivateKey = null; try {/*from ww w . j a v a 2 s .c o m*/ try (InputStream keyFileStream = FossologySettings.class.getResourceAsStream(keyFilePath)) { if (keyFileStream == null) throw new IOException("cannot open " + keyFilePath); fossologyPrivateKey = IOUtils.toByteArray(keyFileStream); } } catch (IOException e) { log.error("Cannot load private key", e); } return fossologyPrivateKey; }