Class SystemTools
java.lang.Object
io.clonecloudstore.common.standard.system.SystemTools
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ThreadFactory
static final ExecutorService
static final ExecutorService
Global Thread pool for Internal actions such as in TeeInputStream, ZstdCompressedInputStream, S3 -
Method Summary
Modifier and TypeMethodDescriptionstatic long
consumeAll
(Iterator<?> iterator) static long
consumeAll
(Stream<?> stream) static void
consumeWhileErrorInputStream
(InputStream inputStream) Consume all InputStream in error case with no errorstatic void
consumeWhileErrorInputStream
(InputStream inputStream, long timeout) Consume all InputStream in error case with no error with a timeoutstatic Object
Get the field from the object named fieldName from Classstatic IOException
silentlyClose
(InputStream inputStream) Silently close InputStream (exception is returned if any)static IOException
silentlyClose
(OutputStream outputStream) Silently close OutputStream (exception is returned if any)static void
silentlyCloseNoException
(InputStream inputStream) Silently close InputStream (no exception)static void
silentlyCloseNoException
(OutputStream outputStream) Silently close OutputStream (no exception)static long
skip
(InputStream inputStream, long skip) Skip bytes from InputStreamstatic Instant
static long
transferTo
(InputStream inputStream, OutputStream outputStream) Transfer all inputStream to outputStreamstatic long
transferTo
(InputStream inputStream, OutputStream outputStream, boolean flushOnChunk) Transfer all inputStream to outputStreamstatic void
wait1ms()
Thread.sleep(1 ms)
-
Field Details
-
VIRTUAL_EXECUTOR_SERVICE
Global Thread pool for Internal actions such as in TeeInputStream, ZstdCompressedInputStream, S3 -
DAEMON_THREAD_FACTORY
-
STANDARD_EXECUTOR_SERVICE
-
-
Method Details
-
toMillis
- Parameters:
instant
- instant to truncate- Returns:
- an Instant truncated to Millisecond (since most of the DB truncated it)
-
silentlyCloseNoException
Silently close InputStream (no exception) -
silentlyClose
Silently close InputStream (exception is returned if any) -
silentlyCloseNoException
Silently close OutputStream (no exception) -
silentlyClose
Silently close OutputStream (exception is returned if any) -
consumeAll
- Parameters:
iterator
- to consume fully- Returns:
- the number of items consumed
-
consumeAll
- Parameters:
stream
- to consume fully- Returns:
- the number of items consumed
-
getField
public static Object getField(Class<?> clasz, String fieldName, Object object) throws NoSuchFieldException, IllegalAccessException Get the field from the object named fieldName from Class- Throws:
NoSuchFieldException
- field does not existIllegalAccessException
- issue on access
-
wait1ms
public static void wait1ms()Thread.sleep(1 ms) -
consumeWhileErrorInputStream
Consume all InputStream in error case with no error -
consumeWhileErrorInputStream
Consume all InputStream in error case with no error with a timeout -
transferTo
public static long transferTo(InputStream inputStream, OutputStream outputStream) throws IOException Transfer all inputStream to outputStream- Returns:
- length of transferred bytes
- Throws:
IOException
-
transferTo
public static long transferTo(InputStream inputStream, OutputStream outputStream, boolean flushOnChunk) throws IOException Transfer all inputStream to outputStream- Returns:
- length of transferred bytes
- Throws:
IOException
-
skip
Skip bytes from InputStream- Returns:
- the number of really skipped bytes
- Throws:
IOException
-