This commit is contained in:
2026-03-11 08:47:22 +08:00
parent 450b4e1a93
commit bc8927db26
71 changed files with 4474 additions and 2471 deletions
@@ -16,7 +16,7 @@
* ProjectName mingli-utils
* ModuleName mingli-utils.main
* CurrentFile ByteBufferUtils.kt
* LastUpdate 2026-01-11 09:44:19
* LastUpdate 2026-03-11 08:46:40
* UpdateUser MingLiPro
*/
@@ -26,6 +26,7 @@ package com.mingliqiye.utils.bytes
import java.io.IOException
import java.io.OutputStream
import java.nio.BufferUnderflowException
import java.nio.ByteBuffer
import java.nio.charset.Charset
@@ -0,0 +1,50 @@
/*
* Copyright 2026 mingliqiye
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ProjectName mingli-utils
* ModuleName mingli-utils.main
* CurrentFile ByteConvertible.kt
* LastUpdate 2026-02-08 10:25:22
* UpdateUser MingLiPro
*/
package com.mingliqiye.utils.bytes
import java.io.OutputStream
import java.io.Serializable
import java.nio.ByteBuffer
interface ByteConvertible : Serializable {
fun toBytes(): ByteArray
fun writeToStream(outputStream: OutputStream) {
outputStream.write(toBytes())
}
fun putToByteBuffer(byteBuffer: ByteBuffer) {
byteBuffer.put(toBytes())
}
companion object {
fun OutputStream.write(byteConvertible: ByteConvertible) {
byteConvertible.writeToStream(this)
}
fun ByteBuffer.put(byteConvertible: ByteConvertible) {
byteConvertible.putToByteBuffer(this)
}
}
}
@@ -16,14 +16,14 @@
* ProjectName mingli-utils
* ModuleName mingli-utils.main
* CurrentFile ByteUtils.kt
* LastUpdate 2026-01-14 13:01:44
* LastUpdate 2026-03-11 08:46:40
* UpdateUser MingLiPro
*/
@file:JvmName("ByteUtils")
package com.mingliqiye.utils.bytes
import com.mingliqiye.utils.base.BASE16
import com.mingliqiye.utils.base.code.Base16
import com.mingliqiye.utils.stream.SuperStream
/**
@@ -125,5 +125,5 @@ fun hexStringToByteArray(string: String): ByteArray {
* @return 对应的十六进制字符串
*/
fun bytesToHex(bytes: ByteArray): String {
return BASE16.encode(bytes)
return Base16.encode(bytes)
}