public class ServerUtil
extends java.lang.Object
| Constructor and Description |
|---|
ServerUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addToClasspath(java.io.File dir)
Adds the specified directory to the current classpath.
|
static void |
addToClasspath(java.lang.String dirName)
Adds the specified directory to the current classpath.
|
static void |
appendToSB(java.io.InputStream in,
java.lang.StringBuilder sb)
Read stream encoded as UTF-8 and add to the resulting string
sb |
static void |
appendToSB0(java.io.InputStream in,
java.lang.StringBuilder sb)
The same as
appendToSB(InputStream, StringBuilder), but contains
throws IOException |
static java.lang.String |
bytesToHex(byte[] bytes)
Converts an array of bytes into their hexadecimal representation
|
static java.io.OutputStream |
copyStreamsAndCloseIn(java.io.InputStream in,
java.io.OutputStream out)
Copies one stream into another, and after copy closes input stream.
|
static void |
deleteRecursively(java.io.File file)
Deletes a file or folder with all its contents
|
static void |
deleteRecursively(java.lang.String fileFullName)
Deletes a file or folder with all its contents
|
static void |
dummyCheck(boolean tmp)
The check which does not perform anything
|
static java.lang.String |
extractName(java.lang.String className)
Extracts class name from the full name of the class
|
static java.lang.String |
extractPackage(java.lang.String className)
Extract the package name from the full name of the class
|
static java.lang.String |
firstUpper(java.lang.String str)
Raise the first letter in upper case
|
static <T> T |
fnn(T... tt)
Return the first element that is not equal to
null |
static java.util.Set<java.io.File> |
getAddedToClassPath()
Receives files list, which were added classpath
|
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.reflect.Method method,
java.lang.Class<T> annotation)
Returns the annotation of the method checking the presence of this annotation at all inherited
methods if they are
|
static java.lang.String |
getVendor() |
static java.lang.String |
getVersion() |
static <T> T |
javaDeserialize(byte[] bytes)
Performs java-serialization of the object and returns the resulting object
|
static byte[] |
javaSerialize(java.lang.Object object)
Performs java-serialization of the object and returns the data resulting after serialization
|
static void |
justOne(int value)
Check the argument for equality to one.
|
static <T> T |
notNull(T t)
Checks that the element was not null, otherwise generates NullPointerException
|
static java.lang.String |
readFile(java.io.File file)
Reads file to string as UTF-8 text
|
static java.io.File |
resolveFile(java.lang.String srcDir,
java.lang.String className,
java.lang.String extension)
Forms the source file (but does not create it) for a specified source-folder and with name of
the class.
|
static byte[] |
streamToByteArray(java.io.InputStream in)
Reads a stream to the end to bytes array, closes a stream, and returns that was read
|
static java.lang.String |
streamToStr(java.io.InputStream in)
Reads and closes the stream, and converts the read information into a string, assuming that it
represented in coding UTF-8
|
static java.lang.String |
streamToStr0(java.io.InputStream in)
The same as
streamToStr(InputStream) but contains throws Exception |
static java.lang.String |
trim(java.lang.String str)
Trims the string on both sides, i.
|
static java.lang.String |
trimLeft(java.lang.String str)
Trims the srting on the left, i.
|
static java.lang.String |
trimRight(java.lang.String str)
Trims the srting on the right, i.
|
public static java.lang.String firstUpper(java.lang.String str)
str - source line@SafeVarargs public static <T> T fnn(T... tt)
nulltt - element listpublic static void dummyCheck(boolean tmp)
public static <T> T notNull(T t)
t - coverage elementpublic static void appendToSB(java.io.InputStream in,
java.lang.StringBuilder sb)
sbin - readable streamsb - dedication to add a stringpublic static void appendToSB0(java.io.InputStream in,
java.lang.StringBuilder sb)
throws java.io.IOException
appendToSB(InputStream, StringBuilder), but contains
throws IOExceptionin - readable streamsb - dedication to add a stringjava.io.IOException - generated in the case of I / O errorspublic static byte[] streamToByteArray(java.io.InputStream in)
in - readable streampublic static java.lang.String streamToStr(java.io.InputStream in)
in - readable streampublic static java.lang.String readFile(java.io.File file)
file - reading filepublic static java.lang.String streamToStr0(java.io.InputStream in)
throws java.lang.Exception
streamToStr(InputStream) but contains throws Exceptionin - readable streamjava.lang.Exception - here are all the errorspublic static java.io.OutputStream copyStreamsAndCloseIn(java.io.InputStream in,
java.io.OutputStream out)
in - readable stream, which is closed after readingout - output streampublic static java.lang.String getVersion()
public static java.lang.String getVendor()
public static void justOne(int value)
value - argument checking for onepublic static java.util.Set<java.io.File> getAddedToClassPath()
public static void addToClasspath(java.io.File dir)
throws java.lang.Exception
dir - the directory which has the compiled classes, and which is not yet in current
classpathjava.lang.Exceptionpublic static void addToClasspath(java.lang.String dirName)
throws java.lang.Exception
dirName - the directory which has the compiled classes, and which is not yet in current
classpath-ะตjava.lang.Exceptionpublic static java.lang.String extractPackage(java.lang.String className)
className - full name of the classpublic static java.io.File resolveFile(java.lang.String srcDir,
java.lang.String className,
java.lang.String extension)
.javasrcDir - the directory where the source codes areclassName - full name of the classextension - extension (if null, .java is used)public static java.lang.String extractName(java.lang.String className)
className - full name of the classpublic static void deleteRecursively(java.io.File file)
file - deletable file or folderpublic static void deleteRecursively(java.lang.String fileFullName)
fileFullName - path to the file or folderpublic static byte[] javaSerialize(java.lang.Object object)
object - serializable objectpublic static <T> T javaDeserialize(byte[] bytes)
bytes - previously serialized datapublic static java.lang.String trim(java.lang.String str)
null there are no errors - null is
returnedstr - string to trimpublic static java.lang.String trimLeft(java.lang.String str)
null there are no errors - null is returnedstr - string to trimpublic static java.lang.String trimRight(java.lang.String str)
null there are no errors - null is returnedstr - string to trimpublic static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.reflect.Method method,
java.lang.Class<T> annotation)
method - source methodannotation - class of required annotationnull if such annotation is not foundpublic static java.lang.String bytesToHex(byte[] bytes)
bytes - source array of bytes or nullnull instead of array of bytes