Examples of DataUtilException


Examples of com.btaz.datautil.DataUtilException

     * @param file new file
     * @return file new file
     */
    public File createFile(File file) throws DataUtilException {
        if(file == null) {
            throw new DataUtilException("File parameter can not be a null value");
        }

        try {
            if(! file.createNewFile()) {
                throw new DataUtilException("Failed to create file. Result of File.createNewFile() was false.");
            }
            trackedFiles.add(file);
        } catch (IOException e) {
            throw new DataUtilException("Failed to create file: " + file.getAbsolutePath(), e);
        }
        return file;
    }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

     * @param dir new directory
     * @return file new directory
     */
    public File createDir(File dir) throws DataUtilException {
        if(dir == null) {
            throw new DataUtilException("Dir parameter can not be a null value");
        }
        if(dir.exists()) {
            throw new DataUtilException("Directory already exists: " + dir.getAbsolutePath());
        }
        if(! dir.mkdir()) {
            throw new DataUtilException("The result of File.mkDir() was false. Failed to create directory. : "
                    + dir.getAbsolutePath());
        }
        trackedFiles.add(dir);
        return dir;
    }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

        assert url != null : "Couldn't load : " + resourceName;
        try {
            return new File(url.toURI());
        } catch (URISyntaxException e) {
            throw new DataUtilException("Couldn't load test resource");
        }
    }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

        Collections.sort(files, filePathComparator);

        for(File file : files) {
            if(file.exists()) {
                if(!file.delete()) {
                    throw new DataUtilException("Couldn't delete a tracked "
                            + (file.isFile()? "file":"directory" + ": ") + file.getAbsolutePath());
                }
            }
        }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

                // no more data
                writer.flush();
                writer.close();
            }
        } catch (IOException e) {
            throw new DataUtilException(e);
        }
    }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

            try {
                inputStream = new FileInputStream(file);
                reader = new BufferedReader(new InputStreamReader(inputStream, DataUtilDefaults.charSet));
                hasMoreData = true;
            } catch (FileNotFoundException e) {
                throw new DataUtilException(e);
            } catch (UnsupportedEncodingException e) {
                throw new DataUtilException(e);
            }
        }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

                    close();
                }
                return line;
            } catch (IOException e) {
                hasMoreData = false;
                throw new DataUtilException(e);
            }
        }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

         */
        private void close() {
            try {
                inputStream.close();
            } catch (IOException e) {
                throw new DataUtilException(e);
            }
        }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

                inputStream.close();
            }
            writer.flush();
            writer.close();
        } catch (UnsupportedEncodingException e) {
            throw new DataUtilException(e);
        } catch (FileNotFoundException e) {
            throw new DataUtilException(e);
        } catch (IOException e) {
            throw new DataUtilException(e);
        }
    }
View Full Code Here

Examples of com.btaz.datautil.DataUtilException

*/
public class FilePathComparator implements Comparator<File> {
    @Override
    public int compare(File o1, File o2) {
        if(o1 == null || o2 == null) {
            throw new DataUtilException("None of the file parameters can be a null value");
        }
        String [] f1 = o1.getAbsolutePath().split(File.separator);
        String [] f2 = o2.getAbsolutePath().split(File.separator);

        for(int i=0; i<Math.min(f1.length, f2.length); i++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.