类 Utils
- java.lang.Object
-
- com.khjxiaogu.MiraiSongPlugin.Utils
-
public final class Utils extends java.lang.Object工具类- 作者:
- khjxiaogu file: Utils.java time: 2020年8月26日
-
-
构造器概要
构造器 构造器 说明 Utils()
-
方法概要
修饰符和类型 方法 说明 static java.lang.StringbytesToHex(byte[] hash)byte array to hex string.
字节串转换为十六进制字符串。static voidexeCmd(java.lang.String commandStr)Execute command,wait until finished.
执行操作平台命令,等待完成。static java.lang.StringgetPlainText(net.mamoe.mirai.message.data.MessageChain msg)Gets the first plain text of the message.
获取消息中的第一条文本.static net.mamoe.mirai.contact.ContactgetRealSender(net.mamoe.mirai.message.MessageEvent ev)Gets the sender to send message.
获取应该发信息的联系人.static longgetTime()Gets current time.
获取当前时间.static booleanisExistent(java.lang.String urlstr)static byte[]readAll(java.io.File i)Read all content from File.
从文件读取全部数据static byte[]readAll(java.io.InputStream i)Read all content from input stream.
从数据流读取全部数据static java.lang.StringremoveLeadings(java.lang.String leading, java.lang.String orig)Removes specific leadings from a string.
替换掉目标字符串的指定开头
-
-
-
方法详细资料
-
readAll
public static byte[] readAll(java.io.InputStream i) throws java.io.IOExceptionRead all content from input stream.
从数据流读取全部数据- 参数:
i- the input stream
数据流- 返回:
- return all read data
返回读入的所有数据 - 抛出:
java.io.IOException- Signals that an I/O exception has occurred.
发生IO错误
-
readAll
public static byte[] readAll(java.io.File i)
Read all content from File.
从文件读取全部数据- 参数:
i- the file
文件- 返回:
- return all read data
返回读入的所有数据
-
getTime
public static long getTime()
Gets current time.
获取当前时间.- 返回:
- time
-
bytesToHex
public static java.lang.String bytesToHex(byte[] hash)
byte array to hex string.
字节串转换为十六进制字符串。- 参数:
hash- the byte array
字节串。- 返回:
- return hex string
返回十六进制字符串。
-
getPlainText
public static java.lang.String getPlainText(net.mamoe.mirai.message.data.MessageChain msg)
Gets the first plain text of the message.
获取消息中的第一条文本.- 参数:
msg- the message to get
需要获取文本的消息- 返回:
- first trimmed plain text
第一条文本,去除首尾空格
-
removeLeadings
public static java.lang.String removeLeadings(java.lang.String leading, java.lang.String orig)Removes specific leadings from a string.
替换掉目标字符串的指定开头- 参数:
leading- the specific leading
指定的开头orig- the original string
源字符串- 返回:
- return result
返回去除的结果
-
getRealSender
public static net.mamoe.mirai.contact.Contact getRealSender(net.mamoe.mirai.message.MessageEvent ev)
Gets the sender to send message.
获取应该发信息的联系人.- 参数:
ev- the message event
消息事件- 返回:
- sender to send message to
应该发信息的联系人
-
exeCmd
public static void exeCmd(java.lang.String commandStr)
Execute command,wait until finished.
执行操作平台命令,等待完成。- 参数:
commandStr- the command string
命令字符串
-
isExistent
public static boolean isExistent(java.lang.String urlstr) throws java.io.IOException- 抛出:
java.io.IOException
-
-