1. 大整数10进制转16进制问题
    google了都没什么好的解决方法,因为要转换的十进制有300多位,long都装不下,没有直接可用的函数可以拿来用
    王总的方法分享之:
    思路:转换10进制字符串为大整数 ,大整数放入字节流,每个字节转换为16进制,有空位补零
    代码:

    import java.math.BigInteger;
    public static String convertDecimalToUpperHexStr(String decimalStr){

    BigInteger bi = new BigInteger(decimalStr);

    byte[] bytes = bi.toByteArray();
    StringBuilder sb = new StringBuilder();
    int i=0;
    for(byte b : bytes) {
    String hexStr = Integer.toHexString(b & 0xFF);
    if (i==0&&"0".equals(hexStr))
    i=1;
    else
    sb.append( hexStr.length()==1?("0"+hexStr):hexStr );
    }
    return sb.toString().toUpperCase();
     }
  2. 有意义的斜杠

    对url http://ip:port/servername post数据有问题,最终发现是因为服务器端把action映射到了“/” 浏览器访问时会自动加斜杠可以获取请求,而客户端端请求无法找到指定action
    导致错误。需要注意理解代码意义。
  3. android eclipse plugin url
    https://dl-ssl.google.com/android/eclipse/
  4. 透过apache nginx等代理获取用户ip
     
    public static String getRemoteAddr(HttpServletRequest req) { 

    String ip = req.getHeader("x-forwarded-for");

    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

    ip = req.getHeader("Proxy-Client-IP");

    }

    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

    ip = req.getHeader("WL-Proxy-Client-IP");

    }

    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

    ip = req.getRemoteAddr();

    }

    return ip;

    }
  5. SVN的cache程序使得你的机器反应很慢的话,那可以参考这个方案.不过可能要改变你以前使用习惯.
    关闭SVN的cache监视。即关闭tsvncache.exe这个程序对目录的监视。
    具体操作步骤如下:
    a) 右击任意目录打开右键菜单,打开"tortoisesvn" => "settings"下的设置窗口
    b) 找到"icon overlays"的设置项,将"status cache"设置成"none"
  6. java异常:java.lang.ClassFormatError: Truncated class file
    实验了好几次 发现突然之间从自己xp机器上maven build的 class文件 拷贝到服务器上不能跑了,从测试机linux环境直接拷贝就没事 无语。
    最终发现是因为ssh里选择了将文件作为binary传输造成的,去掉该选项就可以了
  7. org.apache.juli.ClassLoaderLogManager not found 
    JAVA_HOME 没有设置 安装后设置为/usr/local/jdk即可
  8. java.net.UnknownHostException sc-server02: sc-server02:
    修改 /etc/hosts
    127.0.0.1 localhost.localdomain localhost sc-server02
  9. IntelliJ IDEA  create patch
    Use the Changes view. In the group by directory mode you can right click on the directory with changes and choose Create Patch from the context menu.
    stackoverflow上的答案,其实很笨拙,在VCS菜单选择create 或 apply patch即可 ,有问题问help菜单!
  10. IntelliJ IDEA  open Multiple Projects change remember
    手贱选了remember 结果不能在新窗口打开了,在preferences 里 general startup/shutdown里把confirm window 选上就可以了
  11. System.currentTimeMillis 问题
    它需要从用户态到内核态切换,在 memcache 每秒上万请求中大量使用会造成性能损耗。
    因此将系统时间 cache 10ms, 在不需要10ms以下精度之处可以使用此方法


     
posted on 2011-12-20 17:58  架构师刀哥  阅读(355)  评论(0编辑  收藏  举报