【Java开源代码栏目提醒】:网学会员--在 Java开源代码编辑为广大网友搜集整理了:BlogUtil.java绩等信息,祝愿广大网友取得需要的信息,参考学习。
package com.opensource.blog.comm;
import java.io.*;
public class BlogUtil {
public BlogUtil() {
}
public static int getStringLength(String txt) {
if (txt != null) {
try {
return txt.getBytes(Constant.CHARSET).length;
}
catch (UnsupportedEncodingException ex) {
return 0;
}
}
else {
return 0;
}
}
public static String getUpWebPath(long userID) {
return "/UserFiles/" + (userID % 20) + "/" + userID + "/";
}
public static String getBlogFileWebPath(long id) {
String filePath = "";
filePath = "user/" + (id % 20) + "/" + id + "/";
return filePath;
}
public static String getBlogFilePath(long id) {
String filePath = Constant.ROOTPATH + getBlogFileWebPath(id);
File ft = new File(filePath);
if (!ft.exists()) {
ft.mkdirs();
}
return filePath;
}
public static String getResultUrl(String msg, String tourl) {
if (tourl == null || tourl.length() == 0 ||
tourl.equals(Constant.RECLOSEWIN)) {
try {
tourl = "tourl = " +
java.net.URLEncoder.encode("javascript:window.close();", "GBK");
}
catch (Exception e) {
}
}
else {
try {
tourl = "tourl=" + java.net.URLEncoder.encode(tourl, "GBK");
}
catch (Exception e) {
}
}
return "/result.jsp?" + "msg=" + msg + "&" + tourl;
}
public static int[] getLogoSize(String logosize) {
int[] logosizes = {80, 31};
if (logosize != null && logosize.length() > 0) {
String[] sizes = logosize.split("\\*");
if (sizes.length == 2) {
try {
logosizes[0] = Integer.parseInt(sizes[0]);
logosizes[1] = Integer.parseInt(sizes[1]);
}
catch (Exception e) {
}
}
}
return logosizes;
}
}