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

📄 clog.java

📁 彩信网关程序,SP程序,包含移动彩信代码和电信彩信代码!供学习之用
💻 JAVA
字号:
package com.hxyh.sanny.mms.cmcc.base;

import java.lang.*;

import java.net.*;
import java.io.*;
import java.util.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

 public class CLog {
  private static boolean m_bShowLog;
  private static String m_sLogTitle;
  private static PrintWriter m_writeBuffer;
  public CLog() {

  }

  public static void main(String[] args) {

//    String arg0="http://127.0.0.1:8080/bussi/acommonbussi";
    String arg0="http://127.0.0.1:8080/bussi/acommonbussi?YH_ZONE=changsha&SRC_TERMINAL_ID=13975113466&DEST_ID=8899&MSG_CONTENT=HELLO%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%200000001&LINKID=0000000000111016783&SERVICE_ID=FREE&YH_GAMENAME=ҵ�����G&SUBTYPE=0&ACCESSNO=91155&YH_MSGID=1&YH_MSGTYPE=MO";
//    if (args.length != 1) {
//      System.out.println("Server name not founud!");
//      return;
//    }

//    else {
//      arg0 = args[0];
//      if (arg0.toLowerCase().indexOf("http://") != 0)
//        arg0 = "http://" + arg0;
//    }
    try {
      java.net.URL theURL = new java.net.URL(arg0);
      java.net.URLConnection conn = theURL.openConnection();
      if (conn instanceof java.net.HttpURLConnection) {
        java.net.HttpURLConnection hConn = (HttpURLConnection) conn;
        hConn.setFollowRedirects(false);
        hConn.connect();
        int code = hConn.getResponseCode();
        String msg = hConn.getResponseMessage();
        if (code == HttpURLConnection.HTTP_OK) {
          System.out.println("Normal response returned:" + code + " " + msg);
          java.util.Map headerMap = hConn.getHeaderFields();
          java.util.Iterator iterEnt = headerMap.entrySet().iterator();
          while (iterEnt.hasNext()) {
            System.out.println(iterEnt.next());
          }
          System.out.println("Hit enter to continue");
          System.in.read();
          java.io.InputStream in = hConn.getInputStream();
          java.io.BufferedInputStream bufIn = new BufferedInputStream(in);
          for (; ; ) {
            int data = bufIn.read();
            if (data == -1)
              break;
            else
              System.out.print( (char) data);
          }
        }
        else {
          System.out.println("Abormal response returned:" + code + " " + msg);
        }
      }
      else {
        System.err.println("Invalid transport protocol: not HTTP!");
        return;
      }
    }
    catch (java.net.MalformedURLException ex) {
      System.err.println("Unable to parse URL!");
      return;
    }
    catch (java.io.IOException ex) {
      System.err.println("I/O Error: " + ex);
      return;
    }

  }

  public static void Init(String sAppName, boolean bShow) {
    m_bShowLog = bShow;
    m_sLogTitle = sAppName;

    //1.0 ��ʼ����־����ض˿�

    //1.1 ��ʼ����־�ļ�
    try {
      SimpleDateFormat sDateFormat = new SimpleDateFormat("MMdd");

      m_writeBuffer =
          new PrintWriter(
          new FileWriter("./log" +
                         sDateFormat.format(new Date(System.currentTimeMillis())) +
                         ".log", true));
    }
    catch (Exception e) {
      System.out.println(e);
      System.exit(2);
    }
  }

  /**
   * log
   *
   * @param aString String
   */
  public static synchronized void log(String aString) {
    if (m_bShowLog)
    {
      System.out.println(m_sLogTitle + aString);

      m_writeBuffer.println(m_sLogTitle + aString);
      m_writeBuffer.flush();
    }
  }

}

⌨️ 快捷键说明

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