Package com.cedarsolutions.exception

Examples of com.cedarsolutions.exception.CedarRuntimeException


        try {
            stream = new FileOutputStream(filePath);
            stream.write(StringUtils.getBytes(contents));
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to write file: " + e.getMessage(), e);
        } finally {
            close(stream);
        }
    }
View Full Code Here


            for (String line : contents) {
                stream.write(StringUtils.getBytes(line));
                stream.write(StringUtils.LINE_ENDING_BYTES);
            }
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to write file: " + e.getMessage(), e);
        } finally {
            close(stream);
        }
    }
View Full Code Here

                if (line != null) {
                    lines.add(line);
                }
            } while (line != null);
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to read file: " + e.getMessage(), e);
        } finally {
            close(bufferedReader);
            close(fileReader);
        }
View Full Code Here

            int character = -1;
            while ((character = bufferedReader.read()) != -1) {
                buffer.append((char) character);
            }
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to read file: " + e.getMessage(), e);
        } finally {
            close(bufferedReader);
            close(fileReader);
        }
View Full Code Here

    public static List<String> getGlobContents(String dirPath, String glob) {
        List<String> contents = new ArrayList<String>();

        File dirFile = new File(dirPath);
        if (!dirFile.exists() || !dirFile.isDirectory()) {
            throw new CedarRuntimeException("Directory does not exist.");
        }

        Paths paths = new Paths(dirPath, glob);
        for (String path : paths.getRelativePaths()) {
            contents.add(normalize(path));
View Full Code Here

        try {
            List<String> contents = new ArrayList<String>();

            File dirFile = new File(dirPath);
            if (!dirFile.exists() || !dirFile.isDirectory()) {
                throw new CedarRuntimeException("Directory does not exist.");
            }

            File[] files = dirFile.listFiles();
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                contents.add(file.getName());
                if (file.isDirectory()) {
                    if (recursive) {
                        List<String> subdir = getDirContents(file.getCanonicalPath(), recursive);
                        for (String entry : subdir) {
                            String path = join(file.getName(), entry);
                            contents.add(path);
                        }
                    }
                }
            }

            return contents;
        } catch (Exception e) {
            throw new CedarRuntimeException("Error getting dir contents: " + e.getMessage(), e);
        }
    }
View Full Code Here

                    close(os);
                    close(is);
                }
            }
        } catch (Exception e) {
            throw new CedarRuntimeException("Error unzipping file: " + e.getMessage(), e);
        } finally {
            close(zip);
        }
    }
View Full Code Here

     * @return UTC date representing the last modified time for the file.
     */
    public static Date getLastModifiedDate(String filePath) {
        File file = new File(filePath);
        if (!file.exists() || !file.isFile()) {
            throw new CedarRuntimeException("File does not exist: " + filePath);
        } else {
            long instant = file.lastModified();
            return new DateTime(instant, DateTimeZone.UTC).toDate();
        }
    }
View Full Code Here

    public synchronized long getElapsedTime() {
        try {
            long elapsedTime = this.stop.getTime() - this.start.getTime();
            return elapsedTime < 0 ? 0 : elapsedTime;
        } catch (NullPointerException e) {
            throw new CedarRuntimeException("Timer has not been properly started and stopped.");
        }
    }
View Full Code Here

    public JAXBContext getJaxbContext(String className) {
        try {
            Class clazz = Class.forName(className);
            return this.getJaxbContext(clazz);
        } catch (Exception e) {
            throw new CedarRuntimeException("Error obtaining JAXB context: " + e.getMessage(), e);
        }
    }
View Full Code Here

TOP

Related Classes of com.cedarsolutions.exception.CedarRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.