This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FtpUtils { | |
private FtpUtils(){} | |
/** | |
* Description: 向FTP服务器上传文件 | |
* @param host FTP服务器hostname | |
* @param port FTP服务器端口 | |
* @param username FTP登录账号 | |
* @param password FTP登录密码 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 主要使用common io里的几个类: | |
* FileUtils | |
* FilenameUtils | |
* IOUtils | |
* | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Slf4j | |
public class HttpClientUtils { | |
private HttpClientUtils(){} | |
public static String doGet(String url, Map<String, String> param) { | |
// 创建Httpclient对象 | |
CloseableHttpClient httpclient = HttpClients.createDefault(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--debug="true" : 打印logback内部状态(默认当logback运行出错时才会打印内部状态 ),配置该属性后打印条件如下(同时满足): | |
1、找到配置文件 2、配置文件是一个格式正确的xml文件 也可编程实现打印内部状态,例如: LoggerContext lc = (LoggerContext) | |
LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc); --> | |
<!-- scan="true" : 自动扫描该配置文件,若有修改则重新加载该配置文件 --> | |
<!-- scanPeriod="30 seconds" : 配置自动扫面时间间隔(单位可以是:milliseconds, seconds, minutes | |
or hours,默认为:milliseconds), 默认为1分钟,scan="true"时该配置才会生效 --> | |
<configuration debug="false" scan="true" scanPeriod="30 seconds" packagingData="true"> | |
<!-- 设置 logger context 名称,一旦设置不可改变,默认为default --> | |
<contextName>myAppName</contextName> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.huacai.utils; | |
import lombok.extern.slf4j.Slf4j; | |
import org.apache.commons.lang3.time.DateUtils; | |
import org.springframework.stereotype.Component; | |
import org.springframework.util.StringUtils; | |
import java.text.DateFormat; | |
import java.text.ParseException; | |
import java.text.ParsePosition; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、获取秒级时间戳与毫秒级时间戳 | |
import time | |
import datetime | |
t = time.time() | |
print (t) #原始时间数据 | |
print (int(t)) #秒级时间戳 | |
print (int(round(t * 1000))) #毫秒级时间戳 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bol = True # 布尔 | |
num = 100000000; # 数字 | |
num2 = 0.0000001; # 数字 | |
str = "fangbei"; # 字符串 | |
str_cn = u"你好,比特币"; # 字符串 中文unicode | |
list = [1, 2, 3, 3, 'fangbei']; # 列表,方括号,可重复,元素类型可不同 | |
tuple = ('shenzhen', 'beijing', '0755', '0755'); # 元组,小括号,和列表相似,但内容不可修改! | |
dict = {'name': "fangbei", 'age': 28}; # 字典,大括号,存储键值对,类似json | |
set = set(['fang', 'bei', 'm']); # 集合,用于去重 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
在Python3中,将对象序列化为JSON对象,即对对象进行json encode编码,使用函数 | |
json.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw) | |
而将JSON对象反序列化为一个python类型,即对对象进行json decode解码,则使用 | |
json.loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
在Python3中,将中文进行urlencode编码使用函数 | |
urllib.parse.quote(string, safe='/', encoding=None, errors=None) | |
而将编码后的字符串urldecode转为中文,则使用 | |
urllib.parse.unquote(string, encoding='utf-8', errors='replace') | |
OlderNewer