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

📄 setkey.java

📁 亚信java实例 移动短信接口 cmpp3.0
💻 JAVA
字号:
package sample;/*  --------------------------------------------------------------------------    Name:       SetKey.java    Title:      CMPP API of ISMG for CMPP1.22    Package:    SetKey Utiliy code for Asiainfo CMPP 1.22 API    Written:    2002-4-3 11:27  Asiainfo    Revised:        Synopsis:    Editor:     TAB=4 -----------------------------------------------------------------------------*/import aiismg.jcmppapi30.CMPPAPI;import java.io.*;public final class SetKey {		public static void main( String argv[] )	{		int nOutput = 0;		byte[]	baKey = new byte[10];		String sLine;		CMPPAPI pCMPPAPI = new CMPPAPI();		pCMPPAPI.SetOption( false );		if( argv.length != 1 ) {			Usage( );			System.exit( 1 );		}		if(pCMPPAPI.InitCMPPAPI( "../config/javacmppc.ini" ) != 0)		{			System.out.println("Fail to call InitAPI!");			System.exit(1);		}				//System.arraycopy( argv[0].getBytes(),0,baKey,0, 10);		baKey = argv[0].getBytes();		if(pCMPPAPI.CMPPSetKey(baKey) != 0)		{			System.out.println("CMPPSetKey fail!");			System.exit(1);		}		try{			FileInputStream pFileStream;			BufferedReader pFileRead;			int nPos = 0;			StringBuffer strFileBody = new StringBuffer();			pFileStream = new FileInputStream( "../config/javacmppc.ini" );			pFileRead = new BufferedReader( new InputStreamReader( (InputStream)pFileStream ) );			while( ( sLine = pFileRead.readLine() ) != null ) {				sLine = sLine.trim();				if( sLine.indexOf( "IcpShareKey=" ) == 0 )				{					strFileBody.append("IcpShareKey=" + new String(baKey)).append(System.getProperty("line.separator"));				}				else				{					strFileBody.append(sLine).append(System.getProperty("line.separator"));				}			}			pFileRead.close();			pFileStream.close();			DataOutputStream pFileWrite = new DataOutputStream(new FileOutputStream("../config/javacmppc.ini" ));			pFileWrite.writeBytes(strFileBody.toString() );			pFileWrite.flush();			pFileWrite.close();		} catch( SecurityException excpt ) {			System.out.println( "Fail to modify ../config/javacmppc.ini" );		} catch( FileNotFoundException fnfex ) {			System.out.println( "Fail to modify ../config/javacmppc.ini" );		} catch( IOException excpt ) {			System.out.println( "Fail to modify ../config/javacmppc.ini" );		}				System.out.println("CMPPSetKey OK!");		System.exit(0);	}	public static void Usage()	{		System.out.println("Usage: SetKey key");		System.out.println(" e.g.:  SetKey 123  # set share key to 123" );		}}

⌨️ 快捷键说明

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