Java Code Examples for org.osgl.util.E#ioException()
The following examples show how to use
org.osgl.util.E#ioException() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppScanner.java From actframework with Apache License 2.0 | 6 votes |
private ProjectLayout probeLayoutPropertiesFile(File appBase) { File f = new File(appBase, ProjectLayout.PROJ_LAYOUT_FILE); if (f.exists() && f.canRead()) { Properties p = new Properties(); InputStream is = IO.is(f); try { p.load(is); } catch (IOException e) { throw E.ioException(e); } finally { IO.close(is); } return ProjectLayout.util.build(p); } else { return null; } }
Example 2
Source File: SimpleMetricStore.java From actframework with Apache License 2.0 | 6 votes |
void write(SimpleMetricStore store) { if (ioError) { return; } ObjectOutputStream oos = null; try { File file = new File(FILE_NAME); oos = new ObjectOutputStream(new FileOutputStream(file)); oos.writeObject(store); } catch (IOException e) { ioError = true; throw E.ioException(e); } finally { IO.close(oos); } }
Example 3
Source File: SObjectResolver.java From actframework with Apache License 2.0 | 5 votes |
private SObject resolveFromURL(String url) { try { Response resp = http().newCall(new Request.Builder().url(url).build()).execute(); return SObject.of(resp.body().byteStream()); } catch (IOException e) { throw E.ioException(e); } }
Example 4
Source File: ProjectLayout.java From actframework with Apache License 2.0 | 5 votes |
public static File file(File parent, String path) { try { return new File(parent, path).getCanonicalFile(); } catch (IOException e) { throw E.ioException(e); } }
Example 5
Source File: AppDescriptor.java From actframework with Apache License 2.0 | 5 votes |
/** * Serialize this `AppDescriptor` and output byte array * * @return * serialize this `AppDescriptor` into byte array */ public byte[] toByteArray() { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(this); return baos.toByteArray(); } catch (IOException e) { throw E.ioException(e); } }
Example 6
Source File: UploadFileStorageService.java From actframework with Apache License 2.0 | 5 votes |
public static ISObject store(FileItemStream fileItemStream, App app) { UploadFileStorageService ss = app.uploadFileStorageService(); try { return ss._store(fileItemStream); } catch (IOException e) { throw E.ioException(e); } }
Example 7
Source File: UploadFileStorageService.java From actframework with Apache License 2.0 | 5 votes |
@Override public synchronized void write(int b) { if (!checkThresholding(1)) { super.write(b); } else { try { fileOutputStream.write(b); } catch (IOException e) { throw E.ioException(e); } } written++; }
Example 8
Source File: UploadFileStorageService.java From actframework with Apache License 2.0 | 5 votes |
@Override public synchronized void write(byte[] b, int off, int len) { if (!checkThresholding(len)) { super.write(b, off, len); } else { try { fileOutputStream.write(b, off, len); } catch (IOException e) { throw E.ioException(e); } } written += len; }
Example 9
Source File: UploadFileStorageService.java From actframework with Apache License 2.0 | 5 votes |
private boolean checkThresholding(int bytes) { if (!exceedThreshold && (written + bytes > threshold)) { exceedThreshold = true; fileOutputStream = createFileOutputStream(); try { fileOutputStream.write(buf, 0, written); } catch (IOException e) { throw E.ioException(e); } } return exceedThreshold; }
Example 10
Source File: UploadFileStorageService.java From actframework with Apache License 2.0 | 5 votes |
private OutputStream createFileOutputStream() { File dir = file.getParentFile(); if (!dir.exists() && !dir.mkdirs()) { throw E.ioException("Cannot create dir: " + dir.getAbsolutePath()); } return IO.buffered(IO.outputStream(file)); }
Example 11
Source File: CliContext.java From actframework with Apache License 2.0 | 5 votes |
private void print0(String template, Object... args) { try { console.print(S.fmt(template, args)); } catch (IOException e) { throw E.ioException(e); } }
Example 12
Source File: CliContext.java From actframework with Apache License 2.0 | 5 votes |
private void println0(String template, Object... args) { try { if (args.length > 0) { template = S.fmt(template); } console.println(template); } catch (IOException e) { throw E.ioException(e); } }
Example 13
Source File: CliOverHttpContext.java From actframework with Apache License 2.0 | 5 votes |
private static ConsoleReader console(ActionContext actionContext, OutputStream os) { try { return new CliOverHttpConsole(actionContext, os); } catch (IOException e) { throw E.ioException(e); } }
Example 14
Source File: TestServerBootstrapClassLoader.java From actframework with Apache License 2.0 | 5 votes |
protected byte[] tryLoadResource(String name) { if (!name.startsWith("act.")) return null; String fn = ClassNames.classNameToClassFileName(name, true); URL url = findResource(fn.substring(1)); if (null == url) return null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IO.copy(url.openStream(), baos); return baos.toByteArray(); } catch (IOException e) { throw E.ioException(e); } }