public final class Utils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
delete(File file)
Delete.
|
static String |
getJspEncoding(InputStream is)
Gets the jsp encoding.
|
static List<String> |
getNamesForLocale(String baseName,
Locale locale)
Gets the names for locale.
|
static Thread |
getThreadByName(String name)
Gets the thread by name.
|
static String |
highlightStream(String name,
InputStream input,
String rendererName,
String encoding)
Highlight stream.
|
static boolean |
isThreadingEnabled()
Checks if is threading enabled.
|
protected static String |
leftPad(String str,
int len,
String fill)
Left pad.
|
static String |
readFile(File file,
String charsetName)
Reads a file on disk.
|
static String |
readStream(InputStream is,
String charsetName)
Reads strings from the intput stream using the given charset.
|
static void |
sendCompressedFile(javax.servlet.http.HttpServletResponse response,
File file)
Send compressed file.
|
static void |
sendFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
File file)
Send file.
|
static float |
toFloat(String num,
float defaultValue)
To float.
|
static int |
toInt(String num,
int defaultValue)
To int.
|
static int |
toIntHex(String num,
int defaultValue)
To int hex.
|
static long |
toLong(Long num,
long defaultValue)
To long.
|
static long |
toLong(String num,
long defaultValue)
To long.
|
public static String readFile(File file, String charsetName) throws IOException
file - to be readcharsetName - the charset nameIOException - Signals that an I/O exception has occurred.public static String readStream(InputStream is, String charsetName) throws IOException
This method uses the system's default charset if the given one is unsupported.
is - the stream from which to readcharsetName - the charset to use when reading the streamIOException - if reading from the stream fails spectacularlypublic static void delete(File file)
file - the filepublic static int toInt(String num, int defaultValue)
num - the numdefaultValue - the default valuepublic static int toIntHex(String num, int defaultValue)
num - the numdefaultValue - the default valuepublic static long toLong(String num, long defaultValue)
num - the numdefaultValue - the default valuepublic static long toLong(Long num, long defaultValue)
num - the numdefaultValue - the default valuepublic static float toFloat(String num, float defaultValue)
num - the numdefaultValue - the default valuepublic static String getJspEncoding(InputStream is) throws IOException
is - the isIOException - Signals that an I/O exception has occurred.public static void sendFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
File file)
throws IOException
request - the requestresponse - the responsefile - the fileIOException - Signals that an I/O exception has occurred.public static Thread getThreadByName(String name)
name - the namepublic static String highlightStream(String name, InputStream input, String rendererName, String encoding) throws IOException
name - the nameinput - the inputrendererName - the renderer nameencoding - the encodingIOException - Signals that an I/O exception has occurred.public static void sendCompressedFile(javax.servlet.http.HttpServletResponse response,
File file)
throws IOException
response - the responsefile - the fileIOException - Signals that an I/O exception has occurred.protected static String leftPad(String str, int len, String fill)
str - the strlen - the lenfill - the fillpublic static List<String> getNamesForLocale(String baseName, Locale locale)
baseName - the base namelocale - the localepublic static boolean isThreadingEnabled()
Copyright © 2009–2020 psi-probe. All rights reserved.