public class Util extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
AUTO_BROWSE
The constant AUTO_BROWSE.
|
static ThreadLocal<Random> |
R
The constant R.
|
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static void |
add(DoubleSupplier f,
double[] data)
Add.
|
static Stream<byte[]> |
binaryStream(String path,
String name,
int skip,
int recordSize)
Binary stream stream.
|
static void |
browse(URI uri)
Browse.
|
static <F,T> Function<F,T> |
cache(Function<F,T> inner)
Cache function.
|
static File |
cacheFile(String url,
String file)
Cache file file.
|
static File |
cacheFile(URI url)
Cache file file.
|
static InputStream |
cacheLocal(String file,
Supplier<InputStream> fn)
Cache local input stream.
|
static InputStream |
cacheLocal(String file,
URI url)
Cache input stream.
|
static InputStream |
cacheStream(String url,
String file)
Cache input stream.
|
static InputStream |
cacheStream(URI url)
Cache input stream.
|
static CharSequence[] |
currentStack()
Current stack string [ ].
|
static TemporalUnit |
cvt(TimeUnit units)
Cvt temporal unit.
|
static String |
dateStr(String formatStr)
Date str string.
|
static InputStream |
get(String url)
Get input stream.
|
static CharSequence |
getCaller()
Gets caller.
|
static <T> T |
getLast(Stream<T> stream)
Gets last.
|
static StackTraceElement[] |
getStackTrace()
Get stack trace stack trace element [ ].
|
static StackTraceElement[] |
getStackTrace(int skip)
Get stack trace stack trace element [ ].
|
static Supplier<InputStream> |
getStreamSupplier(URI url)
Gets stream supplier.
|
static void |
layout(Component c)
Layout.
|
static BufferedImage |
maximumSize(BufferedImage image,
int width)
Resize buffered png.
|
static String |
mkString(CharSequence separator,
CharSequence... strs)
Mk string string.
|
static String |
pathTo(File from,
File to)
Path to string.
|
static Path |
pathToFile(File baseFile,
File file)
Path to run file path.
|
static byte[] |
read(DataInputStream i,
int s)
Read byte [ ].
|
static void |
report(CharSequence... fragments)
Report.
|
static void |
report(Stream<CharSequence> fragments)
Report.
|
static void |
runAllParallel(Runnable... runnables)
Run all.
|
static void |
runAllSerial(Runnable... runnables)
Run all serial.
|
static void |
sleep(int i)
Sleep.
|
static String |
stripPrefix(String str,
String prefix)
Strip prefix string.
|
static BufferedImage |
toImage(Component component)
To png buffered png.
|
static CharSequence |
toInlineImage(BufferedImage img,
String alt)
To inline png string.
|
static CharSequence |
toInlineImage(LabeledObject<BufferedImage> img)
To inline png string.
|
static <T> Stream<T> |
toIterator(Iterator<T> iterator)
To iterator stream.
|
static <T> Stream<T> |
toStream(Iterator<T> iterator)
To stream stream.
|
static <T> Stream<T> |
toStream(Iterator<T> iterator,
int size)
To stream stream.
|
static <T> Stream<T> |
toStream(Iterator<T> iterator,
int size,
boolean parallel)
To stream stream.
|
static String |
toString(Consumer<PrintStream> fn)
To string string.
|
static String |
toString(Path path)
To string string.
|
static String |
toString(StackTraceElement[] stack)
To string string.
|
static String |
toString(StackTraceElement[] stack,
CharSequence delimiter)
To string string.
|
static UUID |
uuid()
Uuid uuid.
|
public static final ThreadLocal<Random> R
public static boolean AUTO_BROWSE
public static void browse(URI uri) throws IOException
uri - the uriIOException - the io exceptionpublic static void add(@Nonnull DoubleSupplier f, @Nonnull double[] data)
f - the fdata - the datapublic static Stream<byte[]> binaryStream(String path, @Nonnull String name, int skip, int recordSize) throws IOException
path - the pathname - the nameskip - the skiprecordSize - the record sizeIOException - the io exceptionpublic static <F,T> Function<F,T> cache(@Nonnull Function<F,T> inner)
F - the type parameterT - the type parameterinner - the heapCopypublic static InputStream cacheLocal(String file, URI url) throws IOException
file - the fileurl - the urlIOException - the io exceptionpublic static InputStream cacheLocal(String file, Supplier<InputStream> fn) throws FileNotFoundException
file - the filefn - the fnFileNotFoundException - the file not found exceptionpublic static Supplier<InputStream> getStreamSupplier(URI url)
url - the urlpublic static InputStream cacheStream(@Nonnull String url, @Nonnull String file) throws IOException, NoSuchAlgorithmException, KeyManagementException
url - the urlfile - the fileIOException - the io exceptionNoSuchAlgorithmException - the no such algorithm exceptionKeyManagementException - the key management exceptionpublic static File cacheFile(@Nonnull String url, @Nonnull String file) throws IOException, NoSuchAlgorithmException, KeyManagementException
url - the urlfile - the fileIOException - the io exceptionNoSuchAlgorithmException - the no such algorithm exceptionKeyManagementException - the key management exceptionpublic static InputStream get(@Nonnull String url) throws NoSuchAlgorithmException, KeyManagementException, IOException
url - the urlNoSuchAlgorithmException - the no such algorithm exceptionKeyManagementException - the key management exceptionIOException - the io exceptionpublic static InputStream cacheStream(@Nonnull URI url) throws IOException, NoSuchAlgorithmException, KeyManagementException
url - the urlIOException - the io exceptionNoSuchAlgorithmException - the no such algorithm exceptionKeyManagementException - the key management exceptionpublic static File cacheFile(@Nonnull URI url) throws IOException, NoSuchAlgorithmException, KeyManagementException
url - the urlIOException - the io exceptionNoSuchAlgorithmException - the no such algorithm exceptionKeyManagementException - the key management exceptionpublic static CharSequence[] currentStack()
@Nonnull public static TemporalUnit cvt(@Nonnull TimeUnit units)
units - the unitspublic static <T> T getLast(@Nonnull Stream<T> stream)
T - the type parameterstream - the streampublic static String mkString(@Nonnull CharSequence separator, CharSequence... strs)
separator - the separatorstrs - the strspublic static String pathTo(@Nonnull File from, @Nonnull File to)
from - the fromto - the to@Nonnull public static byte[] read(@Nonnull DataInputStream i, int s) throws IOException
i - thes - the sIOException - the io exceptionpublic static void report(@Nonnull Stream<CharSequence> fragments) throws IOException
fragments - the fragmentsIOException - the io exceptionpublic static void report(CharSequence... fragments) throws IOException
fragments - the fragmentsIOException - the io exception@Nullable public static BufferedImage maximumSize(@Nullable BufferedImage image, int width)
image - the pngwidth - the widthpublic static BufferedImage toImage(Component component)
component - the componentpublic static CharSequence toInlineImage(BufferedImage img, String alt)
img - the imgalt - the altpublic static CharSequence toInlineImage(@Nonnull LabeledObject<BufferedImage> img)
img - the imgpublic static <T> Stream<T> toIterator(@Nonnull Iterator<T> iterator)
T - the type parameteriterator - the iteratorpublic static <T> Stream<T> toStream(@Nonnull Iterator<T> iterator)
T - the type parameteriterator - the iteratorpublic static <T> Stream<T> toStream(@Nonnull Iterator<T> iterator, int size)
T - the type parameteriterator - the iteratorsize - the sizepublic static <T> Stream<T> toStream(@Nonnull Iterator<T> iterator, int size, boolean parallel)
T - the type parameteriterator - the iteratorsize - the sizeparallel - the parallelpublic static UUID uuid()
public static void sleep(int i)
i - the@Nonnull public static String dateStr(String formatStr)
formatStr - the format str@Nonnull public static String stripPrefix(String str, String prefix)
str - the strprefix - the prefixpublic static Path pathToFile(File baseFile, @Nonnull File file)
baseFile - the base filefile - the file@Nonnull public static String toString(Path path)
path - the pathpublic static void runAllParallel(@Nonnull Runnable... runnables)
runnables - the runnablespublic static void runAllSerial(@Nonnull Runnable... runnables)
runnables - the runnablespublic static String toString(@Nonnull Consumer<PrintStream> fn)
fn - the fnpublic static String toString(StackTraceElement[] stack)
stack - the stackpublic static String toString(StackTraceElement[] stack, CharSequence delimiter)
stack - the stackdelimiter - the delimiterpublic static StackTraceElement[] getStackTrace()
public static StackTraceElement[] getStackTrace(int skip)
skip - the skippublic static CharSequence getCaller()
Copyright © 2019 SimiaCryptus Software. All rights reserved.