smlcoder.java
来自「Java游戏高级编程!!很不错的!!!Java游戏高级编程!!很不错的」· Java 代码 · 共 88 行
JAVA
88 行
package com.croftsoft.core.text.sml;
import com.croftsoft.core.lang.StringLib;
/*********************************************************************
* Static methods for encoding and decoding SML.
*
* <p>
* Java 1.1 compatible.
* </p>
*
* @version
* 2001-08-09
* @since
* 2001-05-14
* @author
* <a href="http://croftsoft.com/">David Wallace Croft</a>
*********************************************************************/
public final class SmlCoder
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
{
public static void main ( String [ ] args )
//////////////////////////////////////////////////////////////////////
{
System.out.println ( encode ( "<>" ) );
System.out.println ( decode ( "<>" ) );
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/*********************************************************************
* Encodes a String for SML transport.
*
* <p>
* Replaces angle brackets.
* </p>
*********************************************************************/
public static String encode ( String s )
//////////////////////////////////////////////////////////////////////
{
if ( s == null )
{
return null;
}
s = StringLib.replace ( s, "<", "<" );
s = StringLib.replace ( s, ">", ">" );
return s;
}
/*********************************************************************
* Decodes an SML String back into a regular String.
*
* <p>
* Substitutes angle brackets.
* </p>
*********************************************************************/
public static String decode ( String s )
//////////////////////////////////////////////////////////////////////
{
if ( s == null )
{
return null;
}
s = StringLib.replace ( s, "<", "<" );
s = StringLib.replace ( s, ">", ">" );
return s;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
private SmlCoder ( ) { }
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?