Package snap.util
Class SnapUtils
java.lang.Object
snap.util.SnapUtils
This class provides general utility methods.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
clone
(T anObj) Returns a clone of the given object (supports List, Map, Cloneable and null).static <T> T
cloneDeep
(T anObj) Clones the given object, recursively, if the object is a collection.static int
Returns result of comparing two values.static boolean
Returns whether to do something once based on given unique id string.static String
Returns a build date string (eg, "Jan-26-03") as generated into BuildInfo.txt at build time.static byte[]
Returns bytes for a class and name/path.static byte[]
Returns a byte array from a File, String path, InputStream, URL, byte[], etc.static byte[]
getBytesOrThrow
(Object aSource) Returns a byte array from a File, String path, InputStream, URL, byte[], etc.static String
Returns the hostname for this machine.static InputStream
getInputStream
(Object aSource) Returns an input stream from a File, String path, URL, byte array, InputStream, etc.static byte[]
getInputStreamBytes
(InputStream aStream) Returns bytes for an input stream.static SnapUtils.Platform
Returns the current platform.static int
Returns the number of processors on this machine.static String
Returns the temp directory for this machine.static String
Returns text string for a class and name/path.static String
Returns text for a source.static RuntimeException
Returns a "not implemented" exception for string (method name).static void
printlnOnce
(PrintStream aStream, String aString) Does a println of a given message to given print writer once.static void
writeBytes
(byte[] bytes, Object aDest) Writes the given bytes to the given output object (string path or file).
-
Field Details
-
isWindows
public static boolean isWindows -
isMac
public static boolean isMac -
isTeaVM
public static boolean isTeaVM -
isWebVM
public static boolean isWebVM
-
-
Constructor Details
-
SnapUtils
public SnapUtils()
-
-
Method Details
-
getPlatform
Returns the current platform. -
clone
public static <T> T clone(T anObj) Returns a clone of the given object (supports List, Map, Cloneable and null). If object not cloneable, returns object. -
cloneDeep
public static <T> T cloneDeep(T anObj) Clones the given object, recursively, if the object is a collection. -
compare
Returns result of comparing two values. -
getTempDir
Returns the temp directory for this machine. -
getBytes
Returns a byte array from a File, String path, InputStream, URL, byte[], etc. -
getBytesOrThrow
Returns a byte array from a File, String path, InputStream, URL, byte[], etc.- Throws:
IOException
-
getInputStreamBytes
Returns bytes for an input stream.- Throws:
IOException
-
getText
Returns text for a source. -
getBytes
Returns bytes for a class and name/path. -
getText
Returns text string for a class and name/path. -
getInputStream
Returns an input stream from a File, String path, URL, byte array, InputStream, etc. -
writeBytes
Writes the given bytes to the given output object (string path or file). -
getHostname
Returns the hostname for this machine. -
getBuildInfo
Returns a build date string (eg, "Jan-26-03") as generated into BuildInfo.txt at build time. -
getProcessorCount
public static int getProcessorCount()Returns the number of processors on this machine. -
doOnce
Returns whether to do something once based on given unique id string. -
printlnOnce
Does a println of a given message to given print writer once. -
notImpl
Returns a "not implemented" exception for string (method name).
-