@Override public void close() { JOrphanUtils.closeQuietly(isr); JOrphanUtils.closeQuietly(fis); JOrphanUtils.closeQuietly(reader); } }
/** * Convert object to boolean, or <code>false</code> if conversion * failed * * @param o * object to convert * @return converted boolean or <code>false</code> if conversion * failed */ public static boolean getBoolean(Object o) { return getBoolean(o, false); }
/** * @param value String value to test * @return true if value is null or empty trimmed */ protected static boolean isNullOrEmptyTrimmed(String value) { return JOrphanUtils.isBlank(value); } }
public static String[] split(String splittee,String splitChar) { return split(splittee,splitChar,true); }
/** * Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump. * <p> * @see #dumpHeap(String, boolean) * @param fileName name of the heap dump file. Must be creatable, i.e. must not exist. * @throws Exception if the MXBean cannot be found, or if there is a problem during invocation */ public static void dumpHeap(String fileName) throws Exception{ dumpHeap(fileName, true); }
/** * Detects if some content starts with the standard XML prefix. * * @param target the content to check * @return true if the document starts with the standard XML prefix. */ public static boolean isXML(byte [] target){ return startsWith(target, XML_PFX,0); }
/** * Converts object to an integer, defaults to <code>0</code> if object is * not convertible or is <code>null</code>. * * @param o * object to convert * @return converted int, or <code>0</code> if conversion failed */ public static int getInt(Object o) { return getInt(o, 0); }
/** * Converts object to a long, defaults to <code>0</code> if object is not * convertible or is <code>null</code> * * @param o * object to convert * @return converted long or <code>0</code> if conversion failed */ public static long getLong(Object o) { return getLong(o, 0); }
/** * Format a date using a given pattern * * @param date * date to format * @param pattern * pattern to use for formatting * @return formatted date, or empty string if date was <code>null</code> * @throws IllegalArgumentException * when <code>pattern</code> is invalid */ public static String formatDate(String date, String pattern) { return formatDate(getCalendar(date, null), pattern); }
/** * Throw {@link IllegalArgumentException} if folder cannot be written to either: * <ul> * <li>Because it exists but is not a folder</li> * <li>Because it exists but is not empty</li> * <li>Because it does not exist but cannot be created</li> * </ul> * @param folder {@link File} * * @throws IllegalArgumentException when folder can't be written to */ public static void canSafelyWriteToFolder(File folder) { canSafelyWriteToFolder(folder, false); } /**
/** * Convert object to float, or <code>0</code> if conversion * failed * * @param o * object to convert * @return converted float or <code>0</code> if conversion * failed */ public static float getFloat(Object o) { return getFloat(o, 0); }
/** * Convert object to double, or <code>0</code> if conversion * failed * * @param o * object to convert * @return converted double or <code>0</code> if conversion * failed */ public static double getDouble(Object o) { return getDouble(o, 0); }
/** * Converts object to a String, defaults to empty string if object is null. * * @param o * object to convert * @return converted String or empty string when conversion failed */ public static String getString(Object o) { return getString(o, ""); }
/** * Initialise the dumper, and report if there is a problem. * This is optional, as the dump methods will initialise if necessary. * * @throws Exception if there is a problem finding the heapDump MXBean */ public static void init() throws Exception { Exception e =getInstance().exception; if (e != null) { throw e; } }
/** * Convert object to char, or ' ' if no conversion can * be applied * * @param o * object to convert * @return converted char or ' ' if conversion failed */ public static char getChar(Object o) { return getChar(o, ' '); }
/** * Format a date using a given pattern * * @param date * date to format * @param pattern * pattern to use for formatting * @return formatted date, or empty string if date was <code>null</code> * @throws IllegalArgumentException * when <code>pattern</code> is invalid */ public static String formatDate(Calendar date, String pattern) { return formatCalendar(date, pattern); }
/** * This method is guaranteed to not throw any exception. If writer is already * closed then does nothing.<br> * Any buffered data is flushed by this method. */ @Override public void close() { JOrphanUtils.closeQuietly(writer); this.writer = null; }
/** * Is a dynamic proxy defined? * * @param proxyHost the host to check * @param proxyPort the port to check * @return {@code true} iff both ProxyPort and ProxyHost are defined. */ protected boolean isDynamicProxy(String proxyHost, int proxyPort){ return !JOrphanUtils.isBlank(proxyHost) && proxyPort > 0; }
/** * Dumps live objects from the heap to the outputFile file in the same format as the hprof heap dump. * <p> * Creates the dump using the file name: dump_yyyyMMdd_hhmmss_SSS.hprof * The dump is created in the current directory. * <p> * @see #dumpHeap(boolean) * @return the name of the dump file that was created * @throws Exception if the MXBean cannot be found, or if there is a problem during invocation */ public static String dumpHeap() throws Exception{ return dumpHeap(true); }
/** * {@inheritDoc} */ @Override public void close() { JOrphanUtils.closeQuietly(OUTPUT); }