public class Utility extends Object
| Constructor and Description |
|---|
Utility() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
cast(Object value,
Class<T> fieldType) |
static <T extends Annotation> |
findField(Class<?> type,
Class<T> annotationClass) |
static byte[] |
getBytesFromFile(String filePath) |
static InputStream |
getResource(String resource) |
static InputStream |
getStreamFromFile(String filePath) |
static String |
getStringFromFile(String filePath)
getStringFromFile
|
static String |
getStringFromFile(String filePath,
String encoding) |
static String |
read(InputStreamReader inputStreamReader) |
static String |
read(InputStream inputStream,
String encoding) |
static boolean |
saveStringToFile(String filePath,
String content,
boolean isOverwrite) |
public static <T extends Annotation> Field findField(Class<?> type, Class<T> annotationClass) throws Exception
Exceptionpublic static String getStringFromFile(String filePath) throws IOException
filePath - disk path or class path , i.e d:\file.txt or classpath:a.txtIOExceptionpublic static String getStringFromFile(String filePath, String encoding) throws IOException
IOExceptionpublic static InputStream getStreamFromFile(String filePath) throws FileNotFoundException
FileNotFoundExceptionpublic static InputStream getResource(String resource)
public static boolean saveStringToFile(String filePath, String content, boolean isOverwrite)
public static byte[] getBytesFromFile(String filePath) throws FileNotFoundException
FileNotFoundExceptionpublic static String read(InputStreamReader inputStreamReader) throws IOException
IOExceptionpublic static String read(InputStream inputStream, String encoding) throws IOException
IOExceptionCopyright © 2016. All rights reserved.