解决 Byte[] 类型 to string 死循环的问题

master
tzg 4 years ago
parent 0b5c7f4c96
commit 9a384a2fc2

@ -7,6 +7,7 @@ import java.nio.charset.Charset;
import java.text.NumberFormat;
import java.util.Set;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
/**
*
@ -784,23 +785,19 @@ public class Convert
* @param charset
* @return
*/
public static String str(Object obj, Charset charset)
{
if (null == obj)
{
public static String str(Object obj, Charset charset) {
if (null == obj) {
return null;
}
if (obj instanceof String)
{
if (obj instanceof String) {
return (String) obj;
}
else if (obj instanceof byte[] || obj instanceof Byte[])
{
return str((Byte[]) obj, charset);
}
else if (obj instanceof ByteBuffer)
{
} else if (obj instanceof byte[]) {
return str((byte[]) obj, charset);
} else if (obj instanceof Byte[]) {
byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj);
return str(bytes, charset);
} else if (obj instanceof ByteBuffer) {
return str((ByteBuffer) obj, charset);
}
return obj.toString();

Loading…
Cancel
Save