List of usage examples for java.io IOException IOException
public IOException()
From source file:model.fileloader.FileLoader.java
protected List<String> getFileContent(String filename) throws IOException { if (!StringUtils.hasText(filename)) throw new IOException(); String workDir = System.getProperty("user.dir"); File file = new File(workDir, filename); Path path = file.toPath();/*from w w w . j ava 2 s . c o m*/ return Files.readAllLines(path); }
From source file:Main.java
/** * Parse a DOM Document from the given XML file. * // w w w . j a v a2 s .co m * @param f File to parse as Document * @return Document * @throws IOException */ public static Document getDocument(File f) throws IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); // never forget this! try { DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(f); } catch (ParserConfigurationException e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } catch (SAXException e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } }
From source file:Main.java
public static void writePath(GeneralPath path, ObjectOutputStream out) throws IOException { PathIterator i = path.getPathIterator(null); float[] data = new float[6]; while (!i.isDone()) { switch (i.currentSegment(data)) { case PathIterator.SEG_MOVETO: out.writeInt(PathIterator.SEG_MOVETO); out.writeFloat(data[0]);//from www . j a va 2 s . co m out.writeFloat(data[1]); break; case PathIterator.SEG_LINETO: out.writeInt(PathIterator.SEG_LINETO); out.writeFloat(data[0]); out.writeFloat(data[1]); break; case PathIterator.SEG_QUADTO: out.writeInt(PathIterator.SEG_QUADTO); out.writeFloat(data[0]); out.writeFloat(data[1]); out.writeFloat(data[2]); out.writeFloat(data[3]); break; case PathIterator.SEG_CUBICTO: out.writeInt(PathIterator.SEG_CUBICTO); out.writeFloat(data[0]); out.writeFloat(data[1]); out.writeFloat(data[2]); out.writeFloat(data[3]); out.writeFloat(data[4]); out.writeFloat(data[5]); break; case PathIterator.SEG_CLOSE: out.writeInt(PathIterator.SEG_CLOSE); break; default: throw new IOException(); } i.next(); } out.writeInt(PATH_IS_DONE); }
From source file:com.orthancserver.OrthancConnection.java
private static InputStream OpenUrl(String urlString) throws IOException { URL url = new URL(urlString); try {/*from w ww. j av a 2s . co m*/ return url.openStream(); } catch (ConnectException e) { throw new IOException(); } }
From source file:jodtemplate.util.Utils.java
public static void createParentFolders(final File file) throws IOException { if (!file.getParentFile().exists()) { final boolean dirsCreated = file.getParentFile().mkdirs(); if (!dirsCreated) { throw new IOException(); }//from w ww . j a va 2 s . co m } }
From source file:com.orange.ocara.tools.AssetsHelper.java
/** * Copy the asset at the specified path to this app's data directory. If the * asset is a directory, its contents are also copied. *///w ww . j a v a 2s . c o m public static void copyAsset(AssetManager assetManager, String rootPath, String path, File targetFolder) throws IOException { String fullPath = StringUtils.isEmpty(path) ? rootPath : rootPath + File.separator + path; // If we have a directory, we make it and recurse. If a file, we copy its // contents. try { String[] contents = assetManager.list(fullPath); // The documentation suggests that list throws an IOException, but doesn't // say under what conditions. It'd be nice if it did so when the path was // to a file. That doesn't appear to be the case. If the returned array is // null or has 0 length, we assume the path is to a file. This means empty // directories will get turned into files. if (contents == null || contents.length == 0) { throw new IOException(); } // Recurse on the contents. for (String entry : contents) { String newPath = StringUtils.isEmpty(path) ? entry : path + File.separator + entry; copyAsset(assetManager, rootPath, newPath, targetFolder); } } catch (IOException e) { File file = new File(targetFolder, path); if (file.getParentFile() != null) { file.getParentFile().mkdirs(); } FileUtils.copyInputStreamToFile(assetManager.open(fullPath), file); } }
From source file:jp.terasoluna.fw.web.struts.plugins.BLogicIOPlugIn_DigesterStub01.java
/** * IOExceptionX??[?B//from w w w .jav a 2s . co m */ @Override public Object parse(InputStream arg0) throws IOException, SAXException { throw new IOException(); }
From source file:org.pdfgal.pdfgal.utils.impl.PDFUtilsImpl.java
@Override public Integer getPages(final String uri) throws IOException { if (StringUtils.isBlank(uri)) { throw new IOException(); }/*from w w w . j a v a2s. c o m*/ final PDDocument document = PDDocument.load(uri); final Integer numberOfPages = document.getNumberOfPages(); document.close(); return numberOfPages; }
From source file:com.navercorp.pinpoint.plugin.httpclient4.HttpClient4PluginTest.java
@Test public void addDefaultHttpRequestRetryHandlerClass() { DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler(); IOException iOException = new IOException(); HttpContext context = new BasicHttpContext(); assertTrue(retryHandler.retryRequest(iOException, 1, context)); assertTrue(retryHandler.retryRequest(iOException, 2, context)); }
From source file:jodtemplate.util.Utils.java
public static void createRequiredFolders(final File targetFolder) throws IOException { createParentFolders(targetFolder);/* w ww . j av a2 s . c om*/ if (!targetFolder.exists()) { final boolean dirCreated = targetFolder.mkdir(); if (!dirCreated) { throw new IOException(); } } }