2018年6月27日星期三

设计模式概述


不錯的文章

设计模式概述

https://quanke.gitbooks.io/design-pattern-java/六个创建型模式.html


2018年6月13日星期三

Spring Boot属性配置文件详解

不錯的文章

http://blog.didispace.com/springbootproperties/

Base 64


RFC2045中有规定:
The encoded output stream must be represented in lines of no more than 76 characters each.
Base64一行不能超过76字符,超过则添加回车换行符。
结合前面博客说的“有回车符,导致JSON格式不符合要求”,那就明白了,对附件进行Base64编码,因为超过76字节,所以要添加回车换行符,后台解析带有回车换行符的JSON字符串就出现“ net.sf.json.JSONException : Unterminated string ”。
问题根源就是回车换行符,那删除就行了,谷歌后又发现一问题,原来“回车换行符(\r\n)”是在Windows才有,而Linux只有换行(\n),Mac只有回车(\r)。
再搜索了一下找到了解决办法,调用字符串对象的replaceAll方法替换掉\r和\n,代码如下
字符串对象.replaceAll("\r|\n", "");
这样就兼容了不同平台。




參考以下:
https://blog.csdn.net/jifengwan/article/details/45460695

AES



筆記如下:

1.  AES線上工具請參考 : https://www.devglan.com/online-tools/aes-encryption-decryption

2. 密钥长度问题

https://blog.csdn.net/jack85986370/article/details/51423188


使用HttpServletRequest , 取得POST JSON


沒有辦法使用request.getParameter方式拿到JSON
目前改用以下方式:

  StringBuffer jsonReq = new StringBuffer();
  String line = null;
  try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null)
jsonReq.append(line);
  } catch (Exception e) { /*report an error*/ }

比較多筆檔案


參考:

1. 以下可用
https://www.scootersoftware.com/vbulletin/showthread.php?14014-Script-to-collect-all-differences-from-all-files-in-two-directories





2. 以下還沒用過
https://www.scootersoftware.com/vbulletin/showthread.php?2216-comparing-multile-files-to-single-output