com.hanzhigu.so.utils.Utils Maven / Gradle / Ivy
The newest version!
package com.hanzhigu.so.utils;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
public class Utils {
public final static String FILENAME_SPILTER = "_";
public final static String FILENAME_PROHIBIT_TO_USE = "[\\/\\\\:?<>*\\|]";
public static List toList(Iterable iterable) {
if (iterable instanceof List) {
return (List) iterable;
}
ArrayList list = new ArrayList();
if (iterable != null) {
for (E e : iterable) {
list.add(e);
}
}
return list;
}
private final static String ENCODE = "UTF-8";
public static String getURLDecoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLDecoder.decode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
public static String getURLEncoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLEncoder.encode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
public static Double getNotNullDouble(Double val) {
return val != null ? val : new Double(0.00);
}
public static Integer getNotNullInteger(Integer val) {
return val != null ? val : new Integer(0);
}
public static void showVersion(){
//TODO read lic product name & version
System.out.println(" ");
System.out.println(" ┏┓ ┏┓ ");
System.out.println(" ┏┛┻━━━┛┻┓ ");
System.out.println(" ┃ ┃ ");
System.out.println(" ┃ ━ ┃ ");
System.out.println(" ┃ ┳┛ ┗┳ ┃ ");
System.out.println(" ┃ ┃ ");
System.out.println(" ┃ ┻ ┃ ");
System.out.println(" ┃ ┃ ");
System.out.println(" ┗━┓ ┏━┛ ");
System.out.println(" ┃ ┃ ");
System.out.println(" ┃ ┃ ");
System.out.println(" ┃ ┗━━━┓ ");
System.out.println(" ┃ ┣┓ ");
System.out.println(" ┃ ┏┛ ");
System.out.println(" ┗┓┓┏━┳┓┏┛ ");
System.out.println(" ┃┫┫ ┃┫┫ ");
System.out.println(" ┗┻┛ ┗┻┛ ");
System.out.println(" ");
}
// public static void main(String[] args) {
// String name="生产订单\\/:*?<>|";
// name = name.replaceAll(FILENAME_PROHIBIT_TO_USE,Utils.FILENAME_SPILTER);
// System.out.println(getURLEncoderString(name));
//
// System.out.println(getURLDecoderString("%e7%94%9f%e4%ba%a7%e8%ae%a2%e5%8d%95"));
//
// String str = "Por/Ti Baby/(Featuring\\Flex)?h*el|o\\/:*?<>|";
// System.out.println(str.replaceAll(FILENAME_PROHIBIT_TO_USE,Utils.FILENAME_SPILTER));
//
// }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy