当前位置: 首页 > news >正文

嘉兴制作网站机构衡水做外贸网站

嘉兴制作网站机构,衡水做外贸网站,旅游网站建设那家好,定制网站建设广告SplitConcatWithAMP 功能描述#xff1a; 1、将字符串数组连接为整个字符串#xff0c; 为连接符 特例#xff1a;如果 array 为 null 或 empty#xff0c;抛出异常。因为这时无法转换#xff01; public static String arrayToStringWithAMP( String[] array ) …SplitConcatWithAMP 功能描述 1、将字符串数组连接为整个字符串 为连接符 特例如果 array 为 null 或 empty抛出异常。因为这时无法转换 public static String arrayToStringWithAMP( String[] array ) throws Exception 2、字符串切割为字符数组为切割符 特例如果 str 为 null抛出异常。这时也无法转换 public static String[] stringToArrayWithAMP( String str ) throws Exception 3、将 转换为 amp; 因为 为特殊字符。注意amp; 的 不做处理 public static String encode( String str ) 4、将 amp; 还原为 public static String decode( String str ) public class SplitConcatWithAMP {//Array to string concat with //If array items contain replace it to amp;public static String arrayToStringWithAMP( String[] array ) throws Exception{if( array null || array.length 0 ){throw new Exception(Array is null or empty, can not convert to string!);}StringBuilder sb new StringBuilder();for( String s : array ){sb.append( encode(s) );sb.append( );}return removeLastAMP( sb.toString() );}//Remove last in stringprivate static String removeLastAMP( String str ){return str.substring( 0, str.length()-1 );}//String to array split with //But if is amp; ,do not splitpublic static String[] stringToArrayWithAMP( String str ) throws Exception{if( str null ){throw new Exception(String is null, Can not convert to array!);}String[] result str.split( (?!amp;) );for( int i0 ; iresult.length ; i ){result[i] decode( result[i] );}return result;}//Encode in String to amp;//But if is amp; ,do not change.public static String encode( String str ){if( str null){return null;}return str.replaceAll( (?!amp;), amp; );}//Decode amp; in string to public static String decode( String str ){if( str null ){return null;}return str.replaceAll( amp;, );}} 演示 public static void main(String[] args) throws Exception {String[] array new String[]{超人, abc, 真的可以区分, 怀amp;疑, gg};//RightSystem.out.println( Right Demo! );System.out.println( Arrays.toString(array) );String temp arrayToStringWithAMP(array);System.out.println( temp );array stringToArrayWithAMP(temp);System.out.println( Arrays.toString( array ) );//ErrorSystem.out.println(Error Demo!);errorDemo();}static void errorDemo(){String string 超人abc真的可以区分怀疑gg;String[] arr string.split( );System.out.println( Arrays.toString(arr) );}输出结果 Right Demo! [超人, abc, 真的可以区分, 怀amp;疑, gg] 超人abc真的amp;可以区分怀amp;疑gg [超人, abc, 真的可以区分, 怀疑, gg] Error Demo! [超人, abc, 真的, 可以区分, 怀, amp;疑, gg] 从上面的Right Demo结果可以看出数组 - 字符串 - 数组 如果数组项中包含 可以正确还原。 如果数组项中包含 amp;会还原为 。但其表达的意义是一致的
http://www.zqtcl.cn/news/474365/

相关文章:

  • 网站建设公司需要有什么东西凡科建站seo
  • 荷泽网站建设买链接做网站 利润高吗
  • 网站嵌套代码网络营销与策划实训
  • 网上做环评立项的网站是哪个网站开发是前端吗
  • 公司网站可以自己建立吗前端网站开发教程
  • 淘宝客导购网站营销推广软件有哪些
  • 专做写字楼出租的网站建设银行北京招聘网站
  • 龙华观澜网站建设酒店网站建设策划
  • 淄博网站排名做版权保护的网站
  • 专业轻电商网站建设公司新闻发布的网站
  • 设计型网站营销存在的问题及改进
  • 南通建设企业网站wordpress 位置地图
  • 无锡本地网站有哪些手机拍摄720全景软件
  • 泉州晋江网站建设费用东莞市住房和城乡建设局门户网站
  • 苏州网站建设哪家便宜平谷手机网站设计
  • 建设项目一次公示网站嘉兴新站seo外包
  • 电子商务网站模板 html专业网站建设服务报价
  • 网页设计和网站建设的区别研发一款app要多少钱
  • seo网站建设方案建个企业网站需要多少钱
  • 搭建网站的软件网页动态设计
  • 好的界面建筑网站甘孜网站建设
  • 电子商务网站创建过程网站排名提升软件
  • 青岛企业如何建网站购买网站建站
  • 广东自考网站建设管理网站做ddns解析
  • 网站建设分类如何重启网站服务器
  • 新蒲建设集团网站怎么把源码做网站
  • 嘉兴建设局网站在线制作头像框
  • 苏州行业网站建设服务网页制作需要学什么技术
  • 二 网站建设的重要性东莞seo建站优化收费
  • 农业公司注册流程及费用快排seo排名软件