⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blogutil.java

📁 用JAVA完成的BLOG采用STRUTS.HIBERNATE.SPRING.框架.直接用ECLIPSE导入就可以发布运行.调试.
💻 JAVA
字号:
package com.laoer.blog.comm;

import java.io.*;

/**
 * <p>Title: 天乙博客</p>
 *
 * <p>Description: 天乙博客系统</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: Laoer.com</p>
 *
 * @author laoer[Gong Tianyi]
 * @version 1.0
 */
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;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -