java片段
小于 1 分钟
java片段
java用法
格式化字符串
String versionTxt=String.format("%s,%s,版本名称:%s 版本号:%s",v.getTitle(),v.getAppId(),v.getVersionName(),UniUtil.getAppVersion(v.getAppId()).get("code"));
String ms = MessageFormat.format("{0,number,#.##}", 3.656);
maven bom
https://www.baeldung.com/spring-maven-bom
springboot
spring api 版本控制 https://github.com/lkqm/spring-api-versioning
<dependency>
<groupId>com.github.lkqm</groupId>
<artifactId>spring-api-versioning</artifactId>
<version>1.4.0</version>
</dependency>
java读取文件
try(BufferedReader br = Files.newBufferedReader(Paths.get("testBufferedWriter.txt"))){
String inValue;
while((inValue = br.readLine())!=null){
System.out.println("Files.newBufferedReader="+inValue);
}
}
List<String> lines = Files.readAllLines(Paths.get("testBufferedWriter.txt"));
for(String line:lines)System.out.println("Files.readAllLines=="+line);
try(BufferedWriter bw = Files.newBufferedWriter(Paths.get("testNewBufferedWriter.txt"))){
for(String d:data){
bw.write(d);
bw.newLine();
}
}
gradle java编码
allprojects {
// 将构建文件统一输出到项目根目录下的 build 文件夹
layout.buildDirectory = File(rootDir, "build/${path.replace(':', '/')}")
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
}