首页 文章 精选 留言 我的

精选列表

搜索[双向转换],共10000篇文章
优秀的个人博客,低调大师

刚才,我们宣布推出了IPv6转换服务

随着海量智能设备的出现和新兴网络技术如5G、物联网的发展,网络应用对IP地址的需求呈现爆炸式增长。 大家所不了解的事实是全球IPv4地址,也就是现在大部分设备在使用的标准地址,已经枯竭。我国7.51亿互联网用户仅有3.38亿个IPv4地址,人均拥有量仅有0.45个IPv4地址。物以稀为贵,继续购买新的IPv4地址,成本势必不断攀升。 2017年11月26日,中共中央办公厅、国务院办公厅印发《推进互联网协议第六版(IPv6)规格部署行动计划》,并发出通知,要求各地区各部门结合实际认真贯彻落实。计划指出,到2018年底,国内用户量排名前50位的商业网站及应用,省部级以上政府和中央企业外网网站系统,中央和省级新闻及广播电视媒体网站等必须全面支持IPv6。 到2020年底,IPv6活跃用户数将超过5亿。 在全球开发者大会WWDC2015上,苹果

优秀的个人博客,低调大师

Java判断String是否是中文,并把中文转换成Unicode

终于建了一个自己个人小站:https://huangtianyu.gitee.io,以后优先更新小站博客,欢迎进站,O(∩_∩)O~~ 见如下代码: /** * 判断是否为中文字符 * @param c * @return */ public boolean isChinese(char c) { Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) { return true; } return false; } /** * 把中文转成Unicode码 * @param str * @return */ public String chineseToUnicode(String str){ String result=""; for (int i = 0; i < str.length(); i++){ int chr1 = (char) str.charAt(i); if(chr1>=19968&&chr1<=171941){//汉字范围 \u4e00-\u9fa5 (中文) result+="\\u" + Integer.toHexString(chr1); }else{ result+=str.charAt(i); } } return result; }

优秀的个人博客,低调大师

RUP大讲堂(第八讲)-基于模型转换的OOAD

我撰写的一些关于RUP的讲义,PDF格式,可在文后点击“附件下载”阅读全文。 本篇内容简介及部分截图: ◇ 分析设计概览 ◇ 分析设计的区别 ◇ 用例分析-如何从例中获取分析类 ◇ 用例设计-如何从分析类转化为设计元素和设计类 ◇ 数据建模 ◇ 分析设计架构因素的考虑 ◇ MDD简介 ◇ 小结 附件:http://down.51cto.com/data/2349894 本文转自肖勇 51CTO博客,原文链接:http://blog.51cto.com/xiaoyong/75841,如需转载请自行联系原作者

优秀的个人博客,低调大师

android XMl 解析神奇xstream 二: 把对象转换成xml

前言:对xstream不理解的请看:android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 1、Javabeen 代码 package com.android10; public class Product { private String name ; private String age ; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } } 2、操作实例 package com.android10; import android.app.Activity; import android.os.Bundle; import com.thoughtworks.xstream.XStream; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.activity_main ); Product product = new Product() ; product.setName( "jhon" ) ; product.setAge( "30" ); System.out.println("sss " + product.getName() + product.getAge() ); //把对象转化为 XML XStream xstream1 = new XStream(); String string = xstream1.toXML( product ) ; System.out.println( "sss"+ string ); //把对象转化为 XML,并且设置别名 XStream xstream2 = new XStream(); xstream2.alias( "blog" , Product.class) ; //修改别名 String string2 = xstream2.toXML( product ) ; System.out.println( "sss"+ string2 ); } } 3、运行效果 <com.android10.Product> <age>30</age> <name>jhon</name> </com.android10.Product> <blog> <age>30</age> <name>jhon</name> </blog> 4、注意事项 在测试的时候,发现 System.out.println( "sss"+ string ); 和 System.out.println( "sss"+ string2 ); 输出的是: sss<com.android10.Product>sss<blog> 开始以为是哪里写错了,最后在 debug 断点调试的时候,发现 string 的值: <com.android10.Product> <age>30</age> <name>jhon</name> </com.android10.Product> 得出的结论是,eclipse控制台无法输出 xml格式的 字符串 5、项目下载 http://download.csdn.net/detail/yanzi2015/8798893

优秀的个人博客,低调大师

Android 基于Aidl的跨进程间双向通信管理中心(类似于聊天室)

得益于最近有点时间和精力,我想起来了一件事。那就是在上家公司,公司要求做一个APP进程间的通信的功能,并不是APP对APP的直接跨进程通信,而是通过一个服务中心,做接收,然后,再转发,避免应用之间耦合性高,不然的话,新增一个APP,其他APP也要进行升级更新(类似于有服务中心的聊天室)。 我就花几个小时写点东西吧,顺便记录一下 大家都知道在Android设备上,有很多方式,比如,广播,socket,共享内存,aidl等,其中广播和aidl都是基于android中iBinder机制 广播: 广播有缺陷,就是效率不高,有时候会遇到广播丢失,或者说广播的队列过长,导致消息发送慢; 共享内存: 共享内存没有安全性可言,而且多线程读写数据的话,会无法控制 socket: socket耦合度较高,内存需要拷贝两次,适用于跨网络 AIDL: 基于binder,效率高;基于C/S架构,分层清晰,功能明确;有Linux的进程ID概念,更加安全等优点 流程图 很简单的架构,所有的APP消息传递都通过Server来做,工程结构如下,center(消息中心),app1,app2都依赖于lib(aidl接口库) 利用aidl中的RemoteCallbackList类(原理和源码我就不多说了,其实Client调用Server是大同小异的,只不过是反者来了一次),来实现client中的接口回调,这样才能从server主动给client发消息,一般我们都是client主动调用Server,现在轮到Server主动调用client 服务端的代码如下,你可以按照你项目的要求来做 package com.helang.messagecenterdemo; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.os.RemoteCallbackList; import android.os.RemoteException; import android.support.annotation.Nullable; import android.util.Log; import com.helang.lib.IMyAidlCallBackInterface; import com.helang.lib.IMyAidlInterface; /** * 消息服务中心(记得在 manifest.xml 加上 android:exported="true") */ public class MyService extends Service { private final static String TAG = MyService.class.getSimpleName(); private RemoteCallbackList<IMyAidlCallBackInterface> callbackList = new RemoteCallbackList<>();//回调的关键(API>=17,才能使用) @Override public void onCreate() { super.onCreate(); } @Nullable @Override public IBinder onBind(Intent intent) { return iBinder; } /** * 实现iBinder */ private IMyAidlInterface.Stub iBinder = new IMyAidlInterface.Stub() { @Override public void sendMessage(String tag, String message) throws RemoteException { callbackList.beginBroadcast(); sendMessageToAllClient(tag,message); Log.d(TAG,"tag="+tag+" message="+message); callbackList.finishBroadcast(); } @Override public void registerListener(IMyAidlCallBackInterface listener) throws RemoteException { callbackList.register(listener);//注册回调listener Log.d(TAG,"registerListener"); } @Override public void unregisterListener(IMyAidlCallBackInterface listener) throws RemoteException { callbackList.unregister(listener);//取消回调listener Log.d(TAG,"unregisterListener"); } }; /** * 发送消息给全部的client(你也可以指定发送给某个client,也可 * 以根据自己的业务来封装一下Bean,记得要实现Parcelable接口来序列化 * @param tag * @param message */ private void sendMessageToAllClient(String tag,String message){ for (int i = 0 ; i < callbackList.getRegisteredCallbackCount();i++){ try { callbackList.getBroadcastItem(i).callback(tag,message); } catch (RemoteException e) { e.printStackTrace(); } } } } Client1和Client2代码是一样的,就是相互发消息: package com.helang.app2; import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import com.helang.lib.IMyAidlCallBackInterface; import com.helang.lib.IMyAidlInterface; public class MainActivity extends AppCompatActivity { private EditText editText; private Button bt_send; private TextView text; private IMyAidlInterface iMyAidlInterface; private ServiceCallBack serviceCallBack; private MyServiceConnection myServiceConnection; private Handler handler = new Handler(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bt_send = findViewById(R.id.bt_send); editText = findViewById(R.id.editText); text = findViewById(R.id.text); bt_send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (iMyAidlInterface != null){ try { iMyAidlInterface.sendMessage("app2",editText.getText().toString().trim()); } catch (RemoteException e) { e.printStackTrace(); } } } }); bindService(); } @Override protected void onDestroy() { super.onDestroy(); unbindService(); } private void bindService(){ myServiceConnection = new MyServiceConnection(); serviceCallBack = new ServiceCallBack(); Intent intent = new Intent(); intent.setComponent(new ComponentName("com.helang.messagecenterdemo", "com.helang.messagecenterdemo.MyService")); startService(intent);//开启远程服务 bindService(intent,myServiceConnection,BIND_AUTO_CREATE);//绑定服务 } private void unbindService(){ if (myServiceConnection != null){ try { iMyAidlInterface.unregisterListener(serviceCallBack); } catch (RemoteException e) { e.printStackTrace(); } unbindService(myServiceConnection); } } /** * 连接Service */ class MyServiceConnection implements ServiceConnection { @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { iMyAidlInterface = IMyAidlInterface.Stub.asInterface(iBinder); handler.post(new Runnable() { @Override public void run() { //注册回调 if (iMyAidlInterface != null){ try { iMyAidlInterface.registerListener(serviceCallBack); } catch (RemoteException e) { e.printStackTrace(); } } } }); } @Override public void onServiceDisconnected(ComponentName componentName) { } } /** * service回到client的类 */ class ServiceCallBack extends IMyAidlCallBackInterface.Stub{ @Override public void callback(final String tag, final String message) throws RemoteException { runOnUiThread(new Runnable() { @Override public void run() { text.append("tag="+tag+" message="+message); } }); } } } 看看效果吧,Client2(app2)发消息给Client1(app1) 顺便说一句,提前打开Center服务,因为android 8.0之后的版本直接远程开启其他App后台进程服务,是行不通了,可以绑定一个前台进程,网上方法有很多,我这里就简单处理了 源码我都放在github:https://github.com/helang1991/MessageCenter 喜欢的就给个star吧

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册