public final class XTools extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
CFG_PREFIX |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
cfgDef(String key,
String def)
获取或设置配置信息
|
static String |
cfgGet(String key)
获取配置信息值
|
static void |
cfgSet(String key,
String val)
设置配置信息
|
static void |
cfgWatch(String prefix,
XConfigs.Watcher watcher)
监听配置信息
|
static Date |
date(Date base,
int offset)
获取以任意时间所在的那一天为基准偏移若干天的00:00:00时刻的date对象
|
static Date |
dateByMonth(Date base,
int monthOffset,
int dayIndex)
获取以某天所在的那一月为基准偏移若干月的某天00:00:00时刻的date对象
|
static Date |
dateBySeason(Date base,
int seasonOffset,
int dayIndex)
获取以某天所在的那一季度为基准偏移若干季度的某天00:00:00时刻的date对象
|
static Date |
dateByWeek(Date base,
int weekOffset,
int dayIndex)
获取以某天所在的那一周为基准偏移若干周的某天00:00:00时刻的date对象
|
static Date |
dateByYear(Date base,
int yearOffset,
int dayIndex)
获取以某天所在的那一年为基准偏移若干年的某天00:00:00时刻的date对象
|
static String |
dateFormat(String format,
Date date)
将date对象转换成相应格式的字符串,线程安全
|
static int |
dateInMonth(Date base)
获取任意一天是一个月中的第几天
|
static int |
dateInSeason(Date base)
获取任意一天是一个季度中的第几天
|
static int |
dateInWeek(Date base)
获取任意一天是一周中的第几天
|
static int |
dateInYear(Date base)
获取任意一天是一年中的第几天
|
static Date |
dateParse(String format,
String dateStr)
将日期字符串转换成相应的date对象,线程安全
|
static int |
dateType(Date date)
获取任意一天的类型
|
static File |
fileToFile(File file,
String path)
将文件复制到另外一个文件
|
static String |
fileToStr(File file,
String charset)
将文件读取成字符串
|
static XHttpExecutor.Response |
http(XHttpExecutor.Request request)
使用默认的请求执行器进行HTTP请求,
如需对HTTP请求进行更复杂的配置,请移步XTools.http(XOption option, XRequest request);方法
|
static XHttpExecutor.Response |
http(XHttpExecutor executor,
XHttpExecutor.Request request)
使用自定义的请求执行器进行HTTP请求
|
static void |
logD(String tag,
String detail,
Object... args)
记录详细信息的日志
|
static void |
logE(String tag,
String error,
Object... args)
记录错误信息的日志
|
static void |
logE(String tag,
Throwable throwable,
String error,
Object... args)
记录错误信息的日志
|
static void |
logN(String tag,
String notice,
Object... args)
记录提示信息的日志
|
static void |
logW(String tag,
String warning,
Object... args)
记录警告信息的日志
|
static void |
logW(String tag,
Throwable throwable,
String warning,
Object... args)
记录警告信息的日志
|
static Date |
lunarToSolar(String lunarDate)
将农历时间转换成阳历时间
|
static String |
md5(File file)
文件MD5散列
|
static String |
md5(String str)
字符串MD5散列
|
static Date |
monthBySeason(Date base,
int seasonOffset,
int monthIndex)
获取以某天所在的那一季度为基准偏移若干季度的某月的一号00:00:00时刻的date对象
|
static Date |
monthByYear(Date base,
int yearOffset,
int monthIndex)
获取以某天所在的那一年为基准偏移若干年的某月的一号00:00:00时刻的date对象
|
static int |
monthInSeason(Date base)
获取任意一天所在的月是那一季度的第几月
|
static int |
monthInYear(Date base)
获取任意一天所在的月是那一年的第几月
|
static Date |
seasonByYear(Date base,
int yearOffset,
int seasonIndex)
获取以某天所在的那一年为基准偏移若干年的某季度的第一天00:00:00时刻的date对象
|
static int |
seasonInYear(Date base)
获取任意一天所在的季度是那一年的第几个季度
|
static String |
sha1(File file)
文件SHA1散列
|
static String |
sha1(String str)
字符串SHA1散列
|
static String |
solarToLunar(Date solarDate)
将阳历时间转化成农历时间
|
static boolean |
strBlank(String str)
判断字符串是否没有可见字符
|
static File |
streamToFile(InputStream inStream,
String path)
将输入流中的全部数据读取成文件
|
static String |
streamToStr(InputStream inStream,
String charset)
将输入流中的全部数据读取成字符串
|
static void |
streamToStream(InputStream inStream,
OutputStream outStream)
将输入流中的全部数据读取到输出流
|
static boolean |
strEmpty(String str)
判断字符串是否为空
|
static String |
strJoin(Collection<String> strSet,
String glue)
将几个字符串用一个固定的字符串连接起来
|
static String |
strJoin(Map<?,?> strMap,
String glueInner,
String glueOuter)
将键值对集合用固定的字符串连接起来
|
static File |
strToFile(String str,
String path,
String charset)
将字符串保存成文件
|
static boolean |
sysLinux()
判断是否是Linux系统
|
static boolean |
sysMacOS()
判断是否是MacOS系统
|
static boolean |
sysMacOSX()
判断是否是MacOSX系统
|
static boolean |
sysWindows()
判断是否是windows系统
|
static Date |
weekByMonth(Date base,
int monthOffset,
int weekIndex)
获取以某天所在的那一月为基准偏移若干月的某周的周一00:00:00时刻的date对象
|
static Date |
weekBySeason(Date base,
int seasonOffset,
int weekIndex)
获取以某天所在的那一季度为基准偏移若干季度的某周的周一00:00:00时刻的date对象
|
static Date |
weekByYear(Date base,
int yearOffset,
int weekIndex)
获取以某天所在的那一年为基准偏移若干年的某周的周一00:00:00时刻的date对象
|
static int |
weekInMonth(Date base)
获取任意一天所在的周是哪个月的第几周
|
static int |
weekInSeason(Date base)
获取任意一天所在的周是哪一季度的第几周
|
static int |
weekInYear(Date base)
获取任意一天所在的周是哪一年的第几周
|
public static XHttpExecutor.Response http(XHttpExecutor.Request request)
request - http请求public static XHttpExecutor.Response http(XHttpExecutor executor, XHttpExecutor.Request request)
executor - http请求执行器request - http请求public static boolean strEmpty(String str)
str - 要判断的字符串public static boolean strBlank(String str)
str - 要判断的字符串public static String strJoin(Collection<String> strSet, String glue)
strSet - 字符串集合glue - 用于连接的字符串public static String strJoin(Map<?,?> strMap, String glueInner, String glueOuter)
strMap - 键值对集合glueInner - 连接键和值的字符串glueOuter - 连接键值对之间的字符串public static File strToFile(String str, String path, String charset) throws IOException
str - 要保存成文件的字符串path - 保存文件的位置charset - 字符串的编码格式IOException - 在保存时可能会发生IO异常public static String fileToStr(File file, String charset) throws IOException
file - 要读取成字符串的文件charset - 字符串的编码格式IOException - 在读取时可能会发生IO异常public static File fileToFile(File file, String path) throws IOException
file - 源文件path - 目标文件的地址IOException - 在复制时可能会发生IO异常public static String streamToStr(InputStream inStream, String charset) throws IOException
inStream - 要读取的输入流,不会关闭该输入流charset - 字符串的编码格式IOException - 在读取时可能会发生IO异常public static File streamToFile(InputStream inStream, String path) throws IOException
inStream - 要读取的输入流,不会关闭该输入流path - 要保存的文件的位置IOException - 在读取时可能会发生IO异常public static void streamToStream(InputStream inStream, OutputStream outStream) throws IOException
inStream - 要读取的输入流,不会关闭该输入流outStream - 要写入的输出流,不会关闭该输出流IOException - 输入输出时可能会发生IO异常public static int dateType(Date date)
date - 任意一天的date对象public static String dateFormat(String format, Date date)
format - 格式字符串date - date对象public static Date dateParse(String format, String dateStr)
format - 格式字符串dateStr - 日期字符串public static Date date(Date base, int offset)
base - 任意时间的date对象,如果为null则以当前时间为基准offset - 偏移的天数public static Date dateByWeek(Date base, int weekOffset, int dayIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准weekOffset - 偏移的周数dayIndex - 那一周的第几天(每周的第一天是周一,周一为0)public static Date dateByMonth(Date base, int monthOffset, int dayIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准monthOffset - 偏移的月数dayIndex - 那一月的第几天(一号为0)public static Date dateBySeason(Date base, int seasonOffset, int dayIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准seasonOffset - 偏移的季度数dayIndex - 那一季度的第几天(一号为0)public static Date dateByYear(Date base, int yearOffset, int dayIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准yearOffset - 偏移的年数dayIndex - 那一年的第几天(第一天为0)public static Date weekByMonth(Date base, int monthOffset, int weekIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准monthOffset - 偏移的月数weekIndex - 那一月的第几周(每周的第一天是周一,每月的第一周是第一个周一所在的那一周,第一周为0)public static Date weekBySeason(Date base, int seasonOffset, int weekIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准seasonOffset - 偏移的季度数weekIndex - 那一季度的第几周(每周的第一天是周一,每季度的第一周是第一个周一所在的那一周,第一周为0)public static Date weekByYear(Date base, int yearOffset, int weekIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准yearOffset - 偏移的年数weekIndex - 那一年的第几周(每周的第一天是周一,每年的第一周是第一个周一所在的那一周,第一周为0)public static Date monthBySeason(Date base, int seasonOffset, int monthIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准seasonOffset - 偏移的季度数monthIndex - 那一季度的第几个月(第一个月为0)public static Date monthByYear(Date base, int yearOffset, int monthIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准yearOffset - 偏移的年数monthIndex - 那一年的第几个月(一月为0)public static Date seasonByYear(Date base, int yearOffset, int seasonIndex)
base - 基准时间的date对象,如果为null则以当前时间为基准yearOffset - 偏移的年数seasonIndex - 那一年的第几个季度(第一个季度为0)public static int dateInWeek(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int dateInMonth(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int dateInSeason(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int dateInYear(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int weekInMonth(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int weekInSeason(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int weekInYear(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int monthInSeason(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int monthInYear(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static int seasonInYear(Date base)
base - 基准时间的date对象,如果为null则以当前时间为基准public static String solarToLunar(Date solarDate)
solarDate - 阳历时间的Date对象public static Date lunarToSolar(String lunarDate)
lunarDate - 农历时间字符串。例1:1992年八月初六。例2:2033年闰冬月廿八public static boolean sysWindows()
public static boolean sysMacOS()
public static boolean sysMacOSX()
public static boolean sysLinux()
public static String cfgDef(String key, String def)
key - 配置键def - 配置值为null时设置的默认值public static void cfgWatch(String prefix, XConfigs.Watcher watcher)
prefix - 配置键前缀watcher - 配置信息监听器public static void logE(String tag, String error, Object... args)
tag - 日志tagerror - 错误信息args - 错误信息中的参数public static void logE(String tag, Throwable throwable, String error, Object... args)
tag - 日志tagthrowable - 异常对象error - 错误信息args - 错误信息中的参数public static void logW(String tag, String warning, Object... args)
tag - 日志tagwarning - 警告信息args - 警告信息中的参数public static void logW(String tag, Throwable throwable, String warning, Object... args)
tag - 日志tagthrowable - 异常对象warning - 告警信息args - 告警信息中的参数public static void logN(String tag, String notice, Object... args)
tag - 日志tagnotice - 提示信息args - 提示信息中的参数Copyright © 2019. All rights reserved.