feat(商城): 添加阿里巴巴代码规范检测
parent
b3ab408b6a
commit
24d4c82955
@ -1,75 +0,0 @@
|
||||
package com.test;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FileRead1 {
|
||||
public static void main(String[] args) {
|
||||
File file1 = new File("E:\\扫黑办聚合码\\打印一张");
|
||||
File file2 = new File("E:\\扫黑办聚合码\\打印两张");
|
||||
File file3 = new File("E:\\扫黑办聚合码\\打印三张");
|
||||
File file4 = new File("E:\\扫黑办聚合码\\打印一张\\1组");
|
||||
File file5 = new File("E:\\扫黑办聚合码\\打印一张\\3组");
|
||||
File file6 = new File("E:\\扫黑办聚合码\\打印一张\\4组");
|
||||
File file7 = new File("E:\\扫黑办聚合码\\打印一张\\5组");
|
||||
List<String> all = new ArrayList<>();
|
||||
List<String> list1 = Arrays.asList(file1.list());
|
||||
List<String> list2 = Arrays.asList(file2.list());
|
||||
List<String> list3 = Arrays.asList(file3.list());
|
||||
List<String> list4 = Arrays.asList(file4.list());
|
||||
List<String> list5 = Arrays.asList(file5.list());
|
||||
List<String> list6 = Arrays.asList(file6.list());
|
||||
List<String> list7 = Arrays.asList(file7.list());
|
||||
all.addAll(list1);
|
||||
all.addAll(list2);
|
||||
all.addAll(list3);
|
||||
all.addAll(list4);
|
||||
all.addAll(list5);
|
||||
all.addAll(list6);
|
||||
all.addAll(list7);
|
||||
|
||||
System.out.println(all.size());
|
||||
|
||||
List<Integer> names = new ArrayList<>();
|
||||
for (String s : all) {
|
||||
if (s.contains("下载")) {
|
||||
continue;
|
||||
}
|
||||
System.out.println(s);
|
||||
String[] split = s.split("-", -1);
|
||||
if (split.length == 1) {
|
||||
String s1 = split[0].trim().split(".png", -1)[0];
|
||||
if (s1.contains(" (") || s1.contains("组")) {
|
||||
continue;
|
||||
}
|
||||
names.add(Integer.parseInt(s1));
|
||||
}
|
||||
if (split.length == 2) {
|
||||
if (Integer.parseInt(split[0].trim()) < 16) {
|
||||
// if (split[1].trim().contains("-")) {
|
||||
// names.add(Integer.parseInt(split[1].trim().split("-.png", -1)[0]));
|
||||
// } else {
|
||||
// }
|
||||
names.add(Integer.parseInt(split[1].trim().split(".png", -1)[0]));
|
||||
// names.add(Integer.parseInt(split[1].trim()));
|
||||
} else {
|
||||
names.add(Integer.parseInt(split[0].trim()));
|
||||
}
|
||||
}
|
||||
if (split.length >= 3) {
|
||||
names.add(Integer.parseInt(split[1].trim()));
|
||||
}
|
||||
}
|
||||
names = names.stream().distinct().collect(Collectors.toList());
|
||||
names.sort(Comparator.comparingInt(o -> o));
|
||||
System.out.println(StringUtils.join(names, ","));
|
||||
System.out.println(names.size());
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.test;
|
||||
|
||||
public class FoodTest {
|
||||
|
||||
class Food {
|
||||
}
|
||||
|
||||
class Fruit extends Food {
|
||||
}
|
||||
|
||||
class Apple extends Fruit {
|
||||
}
|
||||
|
||||
class Origin extends Fruit {
|
||||
}
|
||||
|
||||
class Plate <T>{
|
||||
private T item;
|
||||
|
||||
public Plate(T t) {
|
||||
item = t;
|
||||
}
|
||||
|
||||
public void set(T t) {
|
||||
item = t;
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new FoodTest().test();
|
||||
}
|
||||
|
||||
public void test() {
|
||||
Plate<? extends Fruit> p = new Plate<>(new Apple());
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.test;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
public class NIOTest {
|
||||
|
||||
private static String name = "E:/data.txt";
|
||||
private static final int BSIZE = 1024;
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
// 写入一个文件:
|
||||
FileChannel fc = new FileOutputStream(name)
|
||||
.getChannel();
|
||||
fc.write(ByteBuffer
|
||||
.wrap("Some text ".getBytes()));
|
||||
// 读取文件e:
|
||||
FileChannel fc2 = new FileInputStream(name)
|
||||
.getChannel();
|
||||
ByteBuffer buff = ByteBuffer.allocate(BSIZE);
|
||||
fc2.read(buff);
|
||||
buff.flip();
|
||||
while (buff.hasRemaining())
|
||||
System.out.write(buff.get());
|
||||
System.out.println();
|
||||
System.out.flush();
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class OSExecute {
|
||||
public static void command(String command) throws Exception {
|
||||
boolean err = false;
|
||||
try {
|
||||
Process process = new ProcessBuilder(
|
||||
command.split(" ")).start();
|
||||
try (
|
||||
BufferedReader results = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
process.getInputStream(), "gbK"));
|
||||
BufferedReader errors = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
process.getErrorStream()))
|
||||
) {
|
||||
results.lines()
|
||||
.forEach(System.out::println);
|
||||
err = errors.lines()
|
||||
.peek(System.err::println)
|
||||
.count() > 0;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (err)
|
||||
throw new Exception(
|
||||
"Errors executing " + command);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
command("java -version");
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.test;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestEOF {
|
||||
public static void main(String[] args) {
|
||||
try (DataInputStream in = new DataInputStream(new FileInputStream("E:/data.txt"))) {
|
||||
while (in.available() != 0) {
|
||||
System.out.write(in.readByte());
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
log.error(e.getMessage(), e);;
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);;
|
||||
}
|
||||
System.out.println(1000== 1000);
|
||||
Integer i1 = 1000;
|
||||
Integer i2 = 1000;
|
||||
System.out.println(i1== i2);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue