• 环境配置
  1. 下载并ZooKeeper的发行版
  2. 新建Java project,并导入jar包
  • 创建会话

public class CreateSession implements Watcher {

private static ZooKeeper zookeeper;

public static void main(String[] args) throws IOException, InterruptedException {

  zookeeper = new ZooKeeper("192.168.1.105:2181",5000,new CreateSession());

  System.out.println(zookeeper.getState());

  Thread.sleep(Integer.MAX_VALUE);

  }

  private void doSomething(){

    System.out.println("do something");

  }

public void process(WatchedEvent event) {

  System.out.println("收到事件:"+event);

  if (event.getState()==KeeperState.SyncConnected){

    if (event.getType()==EventType.None && null==event.getPath()){

      doSomething();

    }

  }

  }

}

  • 同步创建节点

public class CreateNodeSync implements Watcher {

  private static ZooKeeper zookeeper;
  public static void main(String[] args) throws IOException, InterruptedException {
    zookeeper = new ZooKeeper("192.168.124.128:2181,192.168.124.128:2182,192.168.124.128:2183",5000,new CreateNodeSync());
    System.out.println(zookeeper.getState());

    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(){
    try {
      String path = zookeeper.create("/test", "test".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
      System.out.println("return path:"+path);
    } catch (KeeperException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
      System.out.println("do something");
    }
  public void process(WatchedEvent event) {
    System.out.println("收到事件:"+event);
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething();
      }
    }
  }
}

  • 异步创建节点

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooDefs.Perms;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
import org.apache.zookeeper.server.auth.DigestAuthenticationProvider;

public class CreateNodeSyncAuth implements Watcher {

  private static ZooKeeper zookeeper;
  private static boolean somethingDone = false;

  public static void main(String[] args) throws IOException, InterruptedException {
    zookeeper = new ZooKeeper("192.168.124.128:2181,192.168.124.128:2182,192.168.124.128:2183",5000,new CreateNodeSyncAuth());
    System.out.println(zookeeper.getState());

    Thread.sleep(Integer.MAX_VALUE);
  }
  /*
  * 权限模式(scheme): ip, digest
  * 授权对象(ID)
  * ip权限模式: 具体的ip地址
  * digest权限模式: username:Base64(SHA-1(username:password))
  * 权限(permission): create(C), DELETE(D),READ(R), WRITE(W), ADMIN(A)
  * 注:单个权限,完全权限,复合权限
  *
  * 权限组合: scheme + ID + permission
  *
  *
  *
  * */
  private void doSomething(){
    try {

      ACL aclIp = new ACL(Perms.READ,new Id("ip","192.168.124.128"));
      ACL aclDigest = new ACL(Perms.READ|Perms.WRITE,new Id("digest",DigestAuthenticationProvider.generateDigest("zhangsan:123456")));
      ArrayList<ACL> acls = new ArrayList<ACL>();
      acls.add(aclDigest);
      acls.add(aclIp);
      //zookeeper.addAuthInfo("digest", "zhangsan:123456".getBytes());
      String path = zookeeper.create("/test", "test".getBytes(), acls, CreateMode.PERSISTENT);
      System.out.println("return path:"+path);

      somethingDone = true;

    } catch (KeeperException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  public void process(WatchedEvent event) {
    
    System.out.println("收到事件:"+event);
    if (event.getState()==KeeperState.SyncConnected){
      if (!somethingDone && event.getType()==EventType.None && null==event.getPath()){
        doSomething();
      }
    }
  }
}


StringCallback{

public void (int rc,String path,Object ctx,String name)

}

rc是result code 服务端响应结果码。客户端可以从这个结果码中识别出API的调用结果,常见的结果码有:

0(OK),接口调用成功

-4(ConnectionLoss),客户端和服务器连接断开

-110(NodeExists) 节点已存在

-112(SessionExpired)会话已过期

path: 接口调用传入的数据节点的节点路径

ctx: 接口调用传入的ctx参数

name: 实际在服务器端创建的节点名


  • 同步删除节点

import java.io.IOException;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;

public class DeleteNodeSync implements Watcher{

  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new DeleteNodeSync());
    System.out.println(zooKeeper.getState().toString());

    Thread.sleep(Integer.MAX_VALUE);

  }

  private void doSomething(ZooKeeper zooKeeper){
    try {
      zooKeeper.delete("/node_7", -1);
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (KeeperException e) {
      e.printStackTrace();
    }
  }

  @Override
  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(zooKeeper);
      }
    }
  }
}

  • 异步删除节点

import java.io.IOException;

import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;

public class DeleteNodeASync implements Watcher{

  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new DeleteNodeASync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(WatchedEvent event){
    zooKeeper.delete("/node_6", -1, new IVoidCallback(),null);
  }

  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(event);
      }
    }
  }

  static class IVoidCallback implements AsyncCallback.VoidCallback{
    public void processResult(int rc, String path, Object ctx) {
      StringBuilder sb = new StringBuilder();
      sb.append("rc="+rc).append("\n");
      sb.append("path"+path).append("\n");
      sb.append("ctx="+ctx).append("\n");
      System.out.println(sb.toString());
    }
  }

}

  • 同步读取节点

import java.io.IOException;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class GetDataSync implements Watcher{
  private static ZooKeeper zooKeeper;
  private static Stat stat = new Stat();

  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new GetDataSync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(ZooKeeper zookeeper){
    zookeeper.addAuthInfo("digest", "jike:123456".getBytes());
    try {
      System.out.println(new String(zooKeeper.getData("/node_4", true, stat)));
    } catch (KeeperException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }

  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(zooKeeper);
      }else{
        if (event.getType()==EventType.NodeDataChanged){
          try {
            System.out.println(new String(zooKeeper.getData(event.getPath(), true, stat)));
            System.out.println("stat:"+stat);
          } catch (KeeperException e) {
            e.printStackTrace();
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
      }

    }
  }

}

  • 异步读取节点

import java.io.IOException;

import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class GetDataASync implements Watcher{
  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new GetDataASync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(ZooKeeper zookeeper){
    zooKeeper.getData("/node_1", true, new IDataCallback(), null);
  }

  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(zooKeeper);
      }else{
        if (event.getType()==EventType.NodeDataChanged){
          try {
            zooKeeper.getData(event.getPath(), true, new IDataCallback(), null);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }
  }
}

  static class IDataCallback implements AsyncCallback.DataCallback{
    public void processResult(int rc, String path, Object ctx, byte[] data,Stat stat) {
      try {
        System.out.println(new String(zooKeeper.getData(path, true, stat)));
        System.out.println("stat:"+stat);
      } catch (KeeperException e) {
        e.printStackTrace();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}

  • 同步节点检测

import java.io.IOException;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class NodeExistsSync implements Watcher{

  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new NodeExistsSync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(ZooKeeper zooKeeper){
    try{
      Stat stat = zooKeeper.exists("/node_1", true);
      System.out.println(stat);
    }catch(Exception e){
    }
  }

  @Override
  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(zooKeeper);
      }else{
        try {
          if (event.getType()==EventType.NodeCreated){
            System.out.println(event.getPath()+" created");
            System.out.println(zooKeeper.exists(event.getPath(), true));
          }
          else if (event.getType()==EventType.NodeDataChanged){
            System.out.println(event.getPath()+" updated");
            System.out.println(zooKeeper.exists(event.getPath(), true));
          }
          else if (event.getType()==EventType.NodeDeleted){
            System.out.println(event.getPath()+" deleted");
            System.out.println(zooKeeper.exists(event.getPath(), true));
          }

         } catch (Exception e) {
         }
      }
    }
  }
}

  • 异步检测节点

import java.io.IOException;

import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class NodeExistsASync implements Watcher{
  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new NodeExistsASync());
  System.out.println(zooKeeper.getState().toString());
  Thread.sleep(Integer.MAX_VALUE);
}

private void doSomething(ZooKeeper zookeeper){
  zooKeeper.exists("/node_1", true, new IStateCallback(), null);
}

public void process(WatchedEvent event) {

if (event.getState()==KeeperState.SyncConnected){
  if (event.getType()==EventType.None && null==event.getPath()){
    doSomething(zooKeeper);
  }else{
    try {
      if (event.getType()==EventType.NodeCreated){
        System.out.println(event.getPath()+" created");
        zooKeeper.exists(event.getPath(), true, new IStateCallback(), null);
      }
      else if (event.getType()==EventType.NodeDataChanged){
        System.out.println(event.getPath()+" updated");
        zooKeeper.exists(event.getPath(), true, new IStateCallback(), null);
      }
      else if (event.getType()==EventType.NodeDeleted){
        System.out.println(event.getPath()+" deleted");
        zooKeeper.exists(event.getPath(), true, new IStateCallback(), null);
      }
    } catch (Exception e) {
    }
  }
}

}


static class IStateCallback implements AsyncCallback.StatCallback{

    public void processResult(int rc, String path, Object ctx, Stat stat) {
      System.out.println("rc:"+rc);
    }
  }
}

  • 同步获取子节点

import java.io.IOException;
import java.util.List;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
public class GetChildrenSync implements Watcher{
  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new GetChildrenSync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(ZooKeeper zooKeeper){
    try {
      List<String> children = zooKeeper.getChildren("/", true);
      System.out.println(children);
    } catch (Exception e) {
    }
  }

  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(zooKeeper);
      }else{
        if (event.getType()==EventType.NodeChildrenChanged){
          try {
            System.out.println(zooKeeper.getChildren(event.getPath(), true));
          } catch (KeeperException e) {
            e.printStackTrace();
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
}

  • 异步获取子节点

import java.io.IOException;
import java.util.List;

import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class GetChildrenASync implements Watcher{
  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new GetChildrenASync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(ZooKeeper zookeeper){
    try {
      zooKeeper.getChildren("/", true, new IChildren2Callback(), null);
    } catch (Exception e) {
    }
  }

  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(zooKeeper);
      }else{
        if (event.getType()==EventType.NodeChildrenChanged){
          zooKeeper.getChildren(event.getPath(), true, new IChildren2Callback(), null);
        }
      }
    }
  }

  static class IChildren2Callback implements AsyncCallback.Children2Callback{
    public void processResult(int rc, String path, Object ctx,List<String> children, Stat stat) {
      StringBuilder sb = new StringBuilder();
      sb.append("rc="+rc).append("\n");
      sb.append("path="+path).append("\n");
      sb.append("ctx="+ctx).append("\n");
      sb.append("children="+children).append("\n");
      sb.append("stat="+stat).append("\n");
      System.out.println(sb.toString());
    }
  }
}

  • 同步更新

import java.io.IOException;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class UpdateNodeSync implements Watcher{
  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new UpdateNodeSync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }
  private void doSomething(ZooKeeper zooKeeper){
    try {
      Stat stat = zooKeeper.setData("/node_6", "123".getBytes(), -1);
      System.out.println("stat:"+stat);
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (KeeperException e) {
    e.printStackTrace();
    }
  }

  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(zooKeeper);
      }
    }
  }
}

  • 异步更新

import java.io.IOException;

import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class UpdateNodeASync implements Watcher{

  private static ZooKeeper zooKeeper;
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    zooKeeper = new ZooKeeper("192.168.1.105:2181",5000,new UpdateNodeASync());
    System.out.println(zooKeeper.getState().toString());
    Thread.sleep(Integer.MAX_VALUE);
  }

  private void doSomething(WatchedEvent event){
    zooKeeper.setData("/node_6", "234".getBytes(), -1, new IStatCallback(),null);
  }

  public void process(WatchedEvent event) {
    if (event.getState()==KeeperState.SyncConnected){
      if (event.getType()==EventType.None && null==event.getPath()){
        doSomething(event);
      }
    }
  }

  static class IStatCallback implements AsyncCallback.StatCallback{

    public void processResult(int rc, String path, Object ctx, Stat stat) {
      StringBuilder sb = new StringBuilder();
      sb.append("rc="+rc).append("\n");
      sb.append("path"+path).append("\n");
      sb.append("ctx="+ctx).append("\n");
      sb.append("Stat="+stat).append("\n");
      System.out.println(sb.toString());
    }
  }
}

zookeeper_03:Java 客户端(原生API)的更多相关文章

  1. ZooKeeper客户端原生API的使用以及ZkClient第三方API的使用

    这两部分内容的介绍主要讲的是节点及节点内容和子节点的操作,并且讲解的节点的事件监听以及ACL授权 ZooKeeper客户端原生API的使用 百度网盘地址: http://pan.baidu.com/s ...

  2. elasticsearch 口水篇(4)java客户端 - 原生esClient

    上一篇(elasticsearch 口水篇(3)java客户端 - Jest)Jest是第三方客户端,基于REST Api进行调用(httpClient),本篇简单介绍下elasticsearch原生 ...

  3. Java 8原生API也可以开发响应式代码?

    前段时间工作上比较忙,这篇文章一直没来得及写,本文是阅读<Java8实战>的时候,了解到Java 8里已经提供了一个异步非阻塞的接口(CompletableFuture),可以实现简单的响 ...

  4. Kubernetes官方java客户端之七:patch操作

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  5. zookeeper原生API做java客户端

    简介 本文是使用apache提供的原生api做zookeeper客户端 jar包 zookeeper-3.4.5.jar   Demo package bjsxt.zookeeper.base; im ...

  6. JAVA客户端API调用memcached两种方式

    1. memcached client for java客户端API:memcached client for java 引入jar包:java-memcached-2.6.2.jar package ...

  7. hadoop系列二:HDFS文件系统的命令及JAVA客户端API

    转载请在页首明显处注明作者与出处 一:说明 此为大数据系列的一些博文,有空的话会陆续更新,包含大数据的一些内容,如hadoop,spark,storm,机器学习等. 当前使用的hadoop版本为2.6 ...

  8. Java原生API操作XML

    使用Java操作XML的开源框架比较多,如著名的Dom4J.JDOM等,但个人认为不管你用那个框架都要对JDK原生的API有所了解才能更得心应手的应用.本篇就来简单了解下原生的XML API. JAV ...

  9. Zookeeper Java客户端API的使用

    1. 原生api         具体查看下面github代码 2. ZkClient ZkClient是Github上一个开源的ZooKeeper客户端.ZkClient在ZooKeeper原生 A ...

  10. Zookeeper系列三:Zookeeper客户端的使用(Zookeeper原生API如何进行调用、ZKClient、Curator)和Zookeeper会话

    一.Zookeeper原生API如何进行调用 准备工作: 首先在新建一个maven项目ZK-Demo,然后在pom.xml里面引入zk的依赖 <dependency> <groupI ...

随机推荐

  1. Android服务端本地窗口FramebufferNativeWindow

    Android窗口系统 我们知道Android系统采用OpenGL来绘制3D图形,OpenGL ES提供了本地窗口(NativeWindow)的概念,无论是在Android平台中还是其他平台中,只要实 ...

  2. ECSHOP首页站内快讯在哪里添加和修改?

    “添加新闻后在首页站内快讯处显示不出来?”.“请问首页中站内快讯(最新文章)在后台哪个位置管理”.“如何让发布的文章进入首页站内快讯”等等诸如此类的问题,经常在论坛里看到一些朋友在询问. 本ECSHO ...

  3. 禁掉a链接的几种方法

    这次遇到链接 先留着  但不能有任何作用的需求  ,我只能说顾客的需求真是多种多样,奇奇怪怪啊 啊啊啊啊啊啊啊啊啊啊啊 我用span代替了a 标签,但是后来想想维护起来可能不太方便  所以上网查资料, ...

  4. Core Bluetooth 概述 【官方文档翻译】

    Core Bluetooth 框架在Mac和iOS平台,为配备了低功耗蓝牙无线技术的设备提供了进行通信所需要的类.例如,您的应用程序可以发现,探索,和低功耗的外围设备进行交互,如心率监视器.数字温控器 ...

  5. C#中精确计时的一点收获

    以下所有代码运行环境:Windows 2003, Intel(R) Core(TM) 2 Duo CPU E8400 @  3.00GHz 2.99GHz,2.96GB内存 根据综合网上的一些文章,精 ...

  6. SQL case when

    jack    1tom    2anni    3poly    4 select buyer_name, ( case ' then '东' ' then '南' ' then '西' ' the ...

  7. 关于javascript 数组的正态分布排序的一道面试题

    最近几天顶着上海40°的凉爽天气找工作,心里是开心的不要不要的,每次面试都是要坐那里出半天汗才能回过神来,感觉到了这个世界对我深深的爱意,言归正传,面试过程中碰到了几次笔试,其中有这么一道题,由于实际 ...

  8. JSP总结2 配置开发环境和firstjsp

    JDK的下载 JAVA_HOME ,CLASSPATH,PATH 的配置,根据安装路径. 然后java -version检测配置OK. 编写helloworld.java   放置在同JDK 盘里.j ...

  9. android学习—should use @string resource警告

    在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "BUTTON", should use @string resource <Button ...

  10. 【搜索引擎Jediael开发笔记】v0.1完整代码

    详细代码请见 E:\Project\[重要]归档代码\SearchEngine归档代码 或 https://code.csdn.net/jediael_lu/jediael/tree/10991c83 ...