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

📄 tools.java~3~

📁 短信平台接口开发例子,java语言实现的。
💻 JAVA~3~
字号:
package business.common;
import java.io.*;
import java.net.*;

/**
 * <p>Title: 工具类</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004.8</p>
 * <p>Company: 掌上通</p>
 * @author hjj
 * @version 1.0
 */

public class Tools {

  public Tools() {
  }

  /**判断字符串是否为空
   *@param s 要判断的字符
   *@return 返回boolean值,true是空, false不是空
   */
  public static boolean isEmpty(String s) {
    return ( (null == s) || (0 == s.trim().length()) );
  }

  /**返回字段值
   *@param s 返回的字符串
   *@return 字符串值
   */
  public static String getvalue(String s) {
    return isEmpty(s) ? "" : s.trim();
  }

  /**
   * 打印错误信息
   * @param  e 异常
   */
  public static void error(java.lang.Throwable e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
  }

  /**
   * 打印一个字符串
   * @param  s 需要打印的字符串
   */
  public static void trace(String s) {
    System.out.println(s);
  }

  /**
   * 关闭FileInputStream
   * @param  fin
   */
  public static void closeFileInputStream(FileInputStream fin) {
    try {
      if (null == fin)
        return;
      else
        fin.close();
    }
    catch (IOException ex) {
      error(ex);
    }
  }
  /**
   * 关闭InputStream
   * @param  in
   */
  public static void closeInputStream(InputStream in) {
    try {
      if (null == in)
        return;
      else
        in.close();
    }
    catch (IOException ex) {
      error(ex);
    }
  }


  /**
   * 关闭OutputStream
   * @param  out
   */
  public static void closeOutputStream(OutputStream out) {
    try {
      if (null == out)
        return;
      else
        out.close();
    }
    catch (IOException ex) {
      error(ex);
    }
  }

  /**
   * 关闭BufferedReader
   * @param  in
   */
  public static void closeBufferedReader(BufferedReader in) {
    try {
      if (null == in)
        return;
      else
        in.close();
    }
    catch (IOException ex) {
      error(ex);
    }
  }

  /**
   * 关闭InputStreamReader
   * @param  isr
   */
  public static void closeInputStreamReader(InputStreamReader isr) {
    try {
      if (null == isr)
        return;
      else
        isr.close();
    }
    catch (IOException ex) {
      error(ex);
    }
  }

  /**
   * 关闭HttpURLConnection
   * @param  conn
   */
  public static void closeHttpURLConnection(HttpURLConnection httpConn) {
    try {
      if (null == httpConn)
        return;
      else
        httpConn.disconnect();
    }
    catch (Exception ex) {
      error(ex);
    }
  }

  /**
   * 关闭PrintWriter
   * @param  pw
   */
  public static void closePrintWriter(PrintWriter pw) {
    try {
      if (null == pw)
        return;
      else
        pw.close();
    }
    catch (Exception ex) {
      error(ex);
    }
  }

}

⌨️ 快捷键说明

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