diff --git a/jlh/pom.xml b/jlh/pom.xml
index 5919466ad0b89809669c7b30d2e0fb81dfe43937..0b0975e6f181cdc1d50964522f16fe9c3b06f33c 100644
--- a/jlh/pom.xml
+++ b/jlh/pom.xml
@@ -10,6 +10,29 @@
4.0.0
jlh
+
+
+
+ io.netty
+ netty-all
+ 4.1.9.Final
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+
\ No newline at end of file
diff --git a/jlh/src/main/java/com/jlh/jdk9/http/Main.java b/jlh/src/main/java/com/jlh/jdk9/http/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..146cf6e01f38790107b5a715b0bde405e8305cdb
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/jdk9/http/Main.java
@@ -0,0 +1,25 @@
+package com.jlh.jdk9.http;
+
+
+//import jdk.incubator.http.HttpClient;
+//import jdk.incubator.http.HttpRequest;
+//import jdk.incubator.http.HttpResponse;
+//
+//import java.io.IOException;
+//import java.net.URI;
+//import java.net.URISyntaxException;
+//import java.nio.charset.Charset;
+//
+///**
+// * Created by jlh
+// * On 2017/3/31 0031.
+// */
+//public class Main {
+// public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {
+// URI httpURI= new URI("https://www.baidu.com");
+// HttpRequest request = HttpRequest.newBuilder(httpURI).GET().build();
+// HttpClient httpClient = HttpClient.newHttpClient();
+// HttpResponse response=httpClient.send(request, (statusCode, responseHeaders) -> HttpResponse.BodyProcessor.asString(Charset.forName("UTF-8")));
+// System.out.println(response);
+// }
+//}
diff --git a/jlh/src/main/java/com/jlh/jdk9/process/Main.java b/jlh/src/main/java/com/jlh/jdk9/process/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..57cd6eea7201fc14346646acc3158ba1e48ea9a8
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/jdk9/process/Main.java
@@ -0,0 +1,22 @@
+package com.jlh.jdk9.process;
+//
+//import java.time.Duration;
+//import java.time.Instant;
+//import java.util.Optional;
+//
+///**
+// * Created by jlh
+// * On 2017/3/31 0031.
+// */
+//public class Main {
+// public static void main(String[] args) {
+// ProcessHandle processHandle = ProcessHandle.current();
+// long PID = processHandle.getPid();
+// System.out.println(PID);
+// ProcessHandle.Info procInfo = processHandle.info();
+// Optional argsp = procInfo.arguments();
+// Optional cmd = procInfo.commandLine();
+// Optional startTime = procInfo.startInstant();
+// Optional cpuUsage = procInfo.totalCpuDuration();
+// }
+//}
diff --git a/jlh/src/main/java/com/jlh/jdk9/trywith/Main.java b/jlh/src/main/java/com/jlh/jdk9/trywith/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..20114a80ba725cc306bbd308cb65d24b45053e6e
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/jdk9/trywith/Main.java
@@ -0,0 +1,19 @@
+package com.jlh.jdk9.trywith;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Created by jlh
+ * On 2017/3/31 0031.
+ */
+public class Main {
+ public static void main(String[] args) throws IOException {
+// InputStream in = System.in;
+// try (in){
+// System.out.println(in.read());
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/Command.java b/jlh/src/main/java/com/jlh/netty/Command.java
new file mode 100644
index 0000000000000000000000000000000000000000..0db8e1981ab73d9128acc25b5e1fe01ed1a585c0
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/Command.java
@@ -0,0 +1,36 @@
+package com.jlh.netty;
+
+import java.io.Serializable;
+
+/**
+ * Created by jlh
+ * On 2017/4/12 0012.
+ */
+public class Command implements Serializable{
+ private String code;
+ private String value;
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "Command{" +
+ "code='" + code + '\'' +
+ ", value='" + value + '\'' +
+ '}';
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/client/HelloClient.java b/jlh/src/main/java/com/jlh/netty/client/HelloClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..0759f73422f7c3aef064feb7b5c3370457557a9f
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/client/HelloClient.java
@@ -0,0 +1,56 @@
+package com.jlh.netty.client;
+
+import com.jlh.netty.Command;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.channel.Channel;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioSocketChannel;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Scanner;
+
+/**
+ * com.jlh.netty.client
+ * Created by ASUS on 2017/4/11.
+ * 19:19
+ */
+public class HelloClient {
+ public static String host = "127.0.0.1";
+ public static int port = 7878;
+ public static void main(String[] args) throws IOException, InterruptedException {
+ EventLoopGroup group = new NioEventLoopGroup();
+ try {
+ Bootstrap b = new Bootstrap();
+ b.group(group)
+ .channel(NioSocketChannel.class)
+ .handler(new ObjectClientInitializer());
+
+ // 连接服务端
+ Channel ch = b.connect(host, port).sync().channel();
+
+ // 控制台输入
+ Scanner in = new Scanner((System.in));
+ for (; ; ) {
+ String code = in.nextLine();
+ String value = in.nextLine();
+ Command c = new Command();
+ c.setCode(code);
+ c.setValue(value);
+ /*
+ * 向服务端发送在控制台输入的文本 并用"\r\n"结尾
+ * 之所以用\r\n结尾 是因为我们在handler中添加了 DelimiterBasedFrameDecoder 帧解码。
+ * 这个解码器是一个根据\n符号位分隔符的解码器。所以每条消息的最后必须加上\n否则无法识别和解码
+ * */
+ ch.writeAndFlush(c);
+ }
+ }
+ finally{
+ group.shutdownGracefully();
+ }
+ }
+
+}
+
diff --git a/jlh/src/main/java/com/jlh/netty/client/HelloClientHandler.java b/jlh/src/main/java/com/jlh/netty/client/HelloClientHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..825d2d39db0833f6e19bc89ba94fc7179358a503
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/client/HelloClientHandler.java
@@ -0,0 +1,29 @@
+package com.jlh.netty.client;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+
+/**
+ * com.jlh.netty.client
+ * Created by ASUS on 2017/4/11.
+ * 19:23
+ */
+public class HelloClientHandler extends SimpleChannelInboundHandler {
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
+
+ System.out.println("Server say : " + msg);
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ System.out.println("Client active ");
+ super.channelActive(ctx);
+ }
+
+ @Override
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+ System.out.println("Client close ");
+ super.channelInactive(ctx);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/client/HelloClientInitializer.java b/jlh/src/main/java/com/jlh/netty/client/HelloClientInitializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..d7e3a1ca679a83bef24920b9496fbd626b63ad63
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/client/HelloClientInitializer.java
@@ -0,0 +1,37 @@
+package com.jlh.netty.client;
+
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.codec.DelimiterBasedFrameDecoder;
+import io.netty.handler.codec.Delimiters;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+
+/**
+ * com.jlh.netty.client
+ * Created by ASUS on 2017/4/11.
+ * 19:22
+ */
+public class HelloClientInitializer extends ChannelInitializer {
+ @Override
+ protected void initChannel(SocketChannel socketChannel) throws Exception {
+
+
+ ChannelPipeline pipeline = socketChannel.pipeline();
+
+ /*
+ * 这个地方的 必须和服务端对应上。否则无法正常解码和编码
+ *
+ * 解码和编码 我将会在下一张为大家详细的讲解。再次暂时不做详细的描述
+ *
+ * */
+ pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
+ pipeline.addLast("decoder", new StringDecoder());
+ pipeline.addLast("encoder", new StringEncoder());
+
+ // 客户端的逻辑
+ pipeline.addLast("handler", new HelloClientHandler());
+
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/client/ObjectClientHandler.java b/jlh/src/main/java/com/jlh/netty/client/ObjectClientHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..0b71e66325615790ce534294b7b3e2c0a11529f5
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/client/ObjectClientHandler.java
@@ -0,0 +1,31 @@
+package com.jlh.netty.client;
+
+import com.jlh.netty.Command;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.SimpleChannelInboundHandler;
+
+/**
+ * Created by jlh
+ * On 2017/4/12 0012.
+ */
+public class ObjectClientHandler extends SimpleChannelInboundHandler {
+
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, Command msg) throws Exception {
+
+ System.out.println("Server say : " + msg);
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ System.out.println("Client active ");
+ super.channelActive(ctx);
+ }
+
+ @Override
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+ System.out.println("Client close ");
+ super.channelInactive(ctx);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/client/ObjectClientInitializer.java b/jlh/src/main/java/com/jlh/netty/client/ObjectClientInitializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..928c50d6fafed766867fc8ffa57acd40139c1c6b
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/client/ObjectClientInitializer.java
@@ -0,0 +1,22 @@
+package com.jlh.netty.client;
+
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.codec.serialization.ClassResolvers;
+import io.netty.handler.codec.serialization.ObjectDecoder;
+import io.netty.handler.codec.serialization.ObjectEncoder;
+
+/**
+ * Created by jlh
+ * On 2017/4/12 0012.
+ */
+public class ObjectClientInitializer extends ChannelInitializer {
+ @Override
+ protected void initChannel(SocketChannel socketChannel) throws Exception {
+ socketChannel.pipeline().addLast(
+ new ObjectEncoder(),
+ new ObjectDecoder(Integer.MAX_VALUE , ClassResolvers.cacheDisabled(null)),
+ new ObjectClientHandler());
+
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/server/HelloServerHandler.java b/jlh/src/main/java/com/jlh/netty/server/HelloServerHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..7d860b1e984e630ae16a002c08cf2d14ad7b591b
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/server/HelloServerHandler.java
@@ -0,0 +1,29 @@
+package com.jlh.netty.server;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+
+import java.net.InetAddress;
+
+/**
+ * com.jlh.netty.server
+ * Created by ASUS on 2017/4/11.
+ * 19:16
+ */
+public class HelloServerHandler extends SimpleChannelInboundHandler {
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
+ // 收到消息直接打印输出
+ System.out.println(ctx.channel().remoteAddress() + " Say : " + msg);
+
+ // 返回客户端消息 - 我已经接收到了你的消息
+ ctx.writeAndFlush("Received your message !\n");
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ System.out.println("RamoteAddress : " + ctx.channel().remoteAddress() + " active !");
+ ctx.writeAndFlush( "Welcome to " + InetAddress.getLocalHost().getHostName() + " service!\n");
+ super.channelActive(ctx);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/server/HelloServerInitializer.java b/jlh/src/main/java/com/jlh/netty/server/HelloServerInitializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..0c19a0a5a670dc05d1432d6a1a552c450611e425
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/server/HelloServerInitializer.java
@@ -0,0 +1,31 @@
+package com.jlh.netty.server;
+
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.codec.DelimiterBasedFrameDecoder;
+import io.netty.handler.codec.Delimiters;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+
+/**
+ * com.jlh.netty.server
+ * Created by ASUS on 2017/4/11.
+ * 19:14
+ */
+public class HelloServerInitializer extends ChannelInitializer {
+ @Override
+ protected void initChannel(SocketChannel socketChannel) throws Exception {
+ ChannelPipeline pipeline = socketChannel.pipeline();
+
+ // 以("\n")为结尾分割的 解码器
+ pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
+
+ // 字符串解码 和 编码
+ pipeline.addLast("decoder", new StringDecoder());
+ pipeline.addLast("encoder", new StringEncoder());
+
+ // 自己的逻辑Handler
+ pipeline.addLast("handler", new HelloServerHandler());
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/server/ObjectServerHandler.java b/jlh/src/main/java/com/jlh/netty/server/ObjectServerHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..de172522f2d2db1d2933883b35149a8146bc5a95
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/server/ObjectServerHandler.java
@@ -0,0 +1,29 @@
+package com.jlh.netty.server;
+
+import com.jlh.netty.Command;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+
+import java.net.InetAddress;
+
+/**
+ * Created by jlh
+ * On 2017/4/12 0012.
+ */
+public class ObjectServerHandler extends SimpleChannelInboundHandler {
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, Command msg) throws Exception {
+ // 收到消息直接打印输出
+ System.out.println(ctx.channel().remoteAddress() + " Say : " + msg);
+
+ // 返回客户端消息 - 我已经接收到了你的消息
+ ctx.writeAndFlush("Received your message !\n");
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ System.out.println("RamoteAddress : " + ctx.channel().remoteAddress() + " active !");
+ ctx.writeAndFlush( "Welcome to " + InetAddress.getLocalHost().getHostName() + " service!\n");
+ super.channelActive(ctx);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/server/ObjectServerInitializer.java b/jlh/src/main/java/com/jlh/netty/server/ObjectServerInitializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..a652567586b2366ab5ec4a50e74535de939309c5
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/server/ObjectServerInitializer.java
@@ -0,0 +1,20 @@
+package com.jlh.netty.server;
+
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.handler.codec.serialization.ClassResolvers;
+import io.netty.handler.codec.serialization.ObjectDecoder;
+import io.netty.handler.codec.serialization.ObjectEncoder;
+
+/**
+ * Created by jlh
+ * On 2017/4/12 0012.
+ */
+public class ObjectServerInitializer extends ChannelInitializer{
+ @Override
+ protected void initChannel(SocketChannel socketChannel) throws Exception {
+ socketChannel.pipeline().addLast(new ObjectEncoder()
+ ,new ObjectDecoder(Integer.MAX_VALUE, ClassResolvers.cacheDisabled(null)
+ ),new ObjectServerHandler());
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/netty/server/ServerMain.java b/jlh/src/main/java/com/jlh/netty/server/ServerMain.java
new file mode 100644
index 0000000000000000000000000000000000000000..8114ad7979b8a4013d9bdbf1cb5273f7ff29da06
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/netty/server/ServerMain.java
@@ -0,0 +1,33 @@
+package com.jlh.netty.server;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+
+/**
+ * com.jlh.netty.server
+ * Created by ASUS on 2017/4/11.
+ * 19:05
+ */
+public class ServerMain {
+ private static final int portNumber = 7878;
+ public static void main(String[] args) throws InterruptedException {
+ EventLoopGroup bossGroup = new NioEventLoopGroup();
+ EventLoopGroup workerGroup = new NioEventLoopGroup();
+ try{
+ ServerBootstrap b = new ServerBootstrap();
+ b.group(bossGroup, workerGroup);
+ b.channel(NioServerSocketChannel.class);
+ b.childHandler(new ObjectServerInitializer());
+ ChannelFuture f = b.bind(portNumber).sync();
+ // 监听服务器关闭监听
+ f.channel().closeFuture().sync();
+
+ }finally {
+ bossGroup.shutdownGracefully();
+ workerGroup.shutdownGracefully();
+ }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/NIO/Main.java b/jlh/src/main/java/com/jlh/viewer/NIO/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..37032fa527d962b699245fd36aac9afc22ffcef5
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/NIO/Main.java
@@ -0,0 +1,35 @@
+package com.jlh.viewer.NIO;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+
+/**
+ * com.jlh.viewer.NIO
+ * Created by ASUS on 2017/4/22.
+ * 13:33
+ */
+public class Main {
+ public static void main(String[] args) throws IOException {
+
+ FileInputStream fileInputStream= new FileInputStream("D:\\work\\workSpace\\test-mvn\\jlh\\src\\main\\java\\com\\jlh\\viewer\\gsonFomartTest.java");
+ FileOutputStream fileOutputStream = new FileOutputStream("D:\\work\\workSpace\\test-mvn\\jlh\\src\\main\\java\\com\\jlh\\viewer\\out.txt");
+ FileChannel fileChannel=fileInputStream.getChannel(),fileChannel1=fileOutputStream.getChannel();
+
+ ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
+ byteBuffer.clear();
+ while (fileChannel.read(byteBuffer)!=-1){
+ byteBuffer.flip();
+ fileChannel1.write(byteBuffer);
+
+ byteBuffer.clear();
+ }
+
+ fileChannel.close();
+ fileChannel1.close();
+ fileOutputStream.close();
+ fileInputStream.close();
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/Test.java b/jlh/src/main/java/com/jlh/viewer/Test.java
new file mode 100644
index 0000000000000000000000000000000000000000..89c15601d93a848297e479b40071c8971360f402
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/Test.java
@@ -0,0 +1,71 @@
+package com.jlh.viewer;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.Executors;
+
+/**
+ * Created by jlh
+ * On 2017/3/24 0024.
+ */
+
+
+public class Test {
+ private static Integer a=1;
+ private static Integer b=a+1;
+
+ public static void main(String[] args) throws IOException {
+ Person[] a= new Person[]{new Person(2),new Person(1),new Person(3)};
+ Arrays.stream(a).forEach(System.out::println);
+ Arrays.sort(a);
+ Arrays.stream(a).forEach(System.out::println);
+ HashMap mp = new HashMap<>();
+ mp.put("key0","0");
+ mp.entrySet().forEach(System.out::println);
+ mp.entrySet().forEach(m->{
+ m.setValue("val"+m.getValue());
+ });
+ mp.entrySet().forEach(System.out::println);
+
+ }
+ public class A{
+ private Integer a=2;
+ public Integer getA(){
+ return a;
+ }
+ }
+
+ public static class Person implements Comparable{
+ private Integer old;
+
+ public Person(Integer old) {
+ this.old = old;
+ }
+
+ public Integer getOld() {
+ return old;
+ }
+
+ public void setOld(Integer old) {
+ this.old = old;
+ }
+
+ @Override
+ public String toString() {
+ return "Person{" +
+ "old=" + old +
+ '}';
+ }
+
+ @Override
+ public int compareTo(Person o) {
+ int res=0;
+ if (this.old=0;index--){
+ if (A[pos]!=A[index])
+ return index+1;
+ }
+ return 0;
+ }
+ public int search (int[] A,int left,int right,int val){
+ int mid = (left+right)/2;
+ if (A[mid]==val)
+ return mid;
+ else if (A[mid] mp = new LinkedHashMap<>();
+ for (int i=0;i0)
+ mp.put(i,num);
+ }
+ ArrayList> list = new ArrayList<>(mp.entrySet());
+ Collections.sort(list, new Comparator>() {
+ @Override
+ public int compare(Map.Entry o1, Map.Entry o2) {
+ return o1.getValue().compareTo(o2.getValue())*-1;
+ }
+ });
+ String[] res=new String [list.size()];
+ for (int i=0;i=0&&a=0&&b tol =new HashSet<>();
+ for (int i=0;i=105)
+ break;
+ fib[sum]=true;
+ pre1=pre2;
+ pre2=sum;
+ }
+ Scanner sc = new Scanner(System.in);
+ while (sc.hasNext()){
+ String input =sc.nextLine();
+ TreeSet flag =new TreeSet<>();
+ for (int i=0;i map = new LinkedHashMap();//LinkedHashMap而不是hashmap!!!!!
+ String key;
+ String filename;
+ String path;
+ while (in.hasNext()) {
+ path = in.next();
+//将路径转换为文件名
+ int id = path.lastIndexOf('\\');
+//如果找不到说明只有文件名没有路径
+ filename = id < 0 ? path : path.substring(id + 1);
+ int linenum = in.nextInt();
+//统计频率
+ key = filename + " " + linenum;
+ if (map.containsKey(key)) {
+ map.put(key, map.get(key) + 1);
+ } else {
+ map.put(key, 1);
+ }
+ }
+
+ in.close();
+
+//对记录进行排序
+ List> list = new LinkedList>(map.entrySet());
+ Collections.sort(list, new Comparator>() {
+ //降序
+ @Override
+ public int compare(Entry arg0, Entry arg1) {
+ return (arg1.getValue() - arg0.getValue()) == 0 ? (arg0.getValue() - arg1.getValue()) : (arg1.getValue() - arg0.getValue());
+ }
+ });
+//只输出前8条
+ int m = 0;
+ for (Map.Entry mapping : list) {
+ m++;
+ if (m <= 8) {
+ String[] str = mapping.getKey().split(" ");
+ String k = str[0].length() > 16 ? str[0].substring(str[0].length() - 16) : str[0];
+ String n = str[1];
+ System.out.println(k + " " + n + " " + mapping.getValue());
+ } else {
+ break;
+ }
+
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/jlh/src/main/java/com/jlh/viewer/acm/MaxInnerRec.java b/jlh/src/main/java/com/jlh/viewer/acm/MaxInnerRec.java
new file mode 100644
index 0000000000000000000000000000000000000000..4f42b25d0c9a4478bb71f1bd284a41ec35845d5a
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/acm/MaxInnerRec.java
@@ -0,0 +1,38 @@
+package com.jlh.viewer.acm;
+
+/**
+ * com.jlh.viewer.acm
+ * Created by ASUS on 2017/4/21.
+ * 15:12
+ */
+public class MaxInnerRec {
+ public int countArea(int[] A, int n) {
+ int max =-1;
+ for (int i=0;i=0){
+ if (A[j]>=A[i]) {
+ num++;
+ j--;
+ }else
+ break;
+ }
+ j=i+1;
+ while (j=A[i]) {
+ num++;
+ j++;
+ }else
+ break;
+ }
+ max = Math.max(num*A[i],max);
+ }
+ return max;
+ }
+
+ public static void main(String[] args) {
+ MaxInnerRec maxInnerRec = new MaxInnerRec();
+ System.out.println(maxInnerRec.countArea(new int[]{281,179,386,165,88,500},6));
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/acm/MaxValInRange.java b/jlh/src/main/java/com/jlh/viewer/acm/MaxValInRange.java
new file mode 100644
index 0000000000000000000000000000000000000000..709e6f5d1751931de2904897e232c400b57b5021
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/acm/MaxValInRange.java
@@ -0,0 +1,77 @@
+package com.jlh.viewer.acm;
+
+import java.util.Scanner;
+
+/**
+ * com.jlh.viewer.acm
+ * Created by ASUS on 2017/4/19.
+ * 19:14
+ */
+public class MaxValInRange {
+
+ public static void main(String[] args) {
+ Scanner sc = new Scanner(System.in);
+ while (sc.hasNext()){
+ int n=sc.nextInt();
+ int m=sc.nextInt();
+ LineTree lineTree =new LineTree(n);
+ for (int i=1;i<=n;i++){
+ int tmp= sc.nextInt();
+ lineTree.update(i,tmp);
+ }
+ for (int i=0;ib){
+ a=a^b;
+ b=a^b;
+ a=a^b;
+ }
+ if (c.equals("U"))
+ lineTree.update(a,b);
+ else
+ System.out.println(lineTree.query(a,b));
+ }
+ }
+ }
+ public static class LineTree{
+ int[] tree;
+ int size;
+ public LineTree(int n){
+ tree= new int[n*4+1];
+ size=n;
+ }
+ public void update (int n,int value){
+ update(1,1,size,n,value);
+ }
+ private int update (int index,int left,int right,int n,int value){
+ if (left==right){
+ tree[index]=value;
+ return value;
+ }else {
+ int mid = (left+right)/2;
+ if (mid>=n)
+ tree[index]=Math.max(update(index*2,left,mid,n,value),tree[index*2+1]);
+ else
+ tree[index]=Math.max(update(index*2+1,mid+1,right,n,value),tree[index*2]);
+ }
+ return tree[index];
+ }
+
+ public int query (int start,int end){
+ return query(1,1,size,start,end);
+ }
+ private int query (int index,int left,int right,int start,int end){
+ if (left>=start&&right<=end)
+ return tree[index];
+ int mid = (left+right)/2;
+ int a = 0,b=0;
+ if (start<=mid)
+ a=query(index*2,left,mid,start,end);
+ if (end>mid)
+ b=query(index*2+1,mid+1,right,start,end);
+
+ return Math.max(a,b);
+ }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/acm/NumbericKeyPad.java b/jlh/src/main/java/com/jlh/viewer/acm/NumbericKeyPad.java
new file mode 100644
index 0000000000000000000000000000000000000000..4b0bba5acde463c4bc1a5f33e01d87a15783e295
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/acm/NumbericKeyPad.java
@@ -0,0 +1,65 @@
+package com.jlh.viewer.acm;
+
+import java.util.Scanner;
+
+/**
+ * com.jlh.viewer.acm
+ * Created by ASUS on 2017/4/19.
+ * 13:44
+ */
+public class NumbericKeyPad {
+ static int[][] flag ={
+ {1,0,0,0,0,0,0,0,0,0},
+ {1,1,1,1,1,1,1,1,1,1},
+ {1,0,1,1,0,1,1,0,1,1},
+ {0,0,0,1,0,0,1,0,0,1},
+ {1,0,0,0,1,1,1,1,1,1},
+ {1,0,0,0,0,1,1,0,1,1},
+ {0,0,0,0,0,0,1,0,0,1},
+ {1,0,0,0,0,0,0,1,1,1},
+ {1,0,0,0,0,0,0,0,1,1},
+ {0,0,0,0,0,0,0,0,0,1}
+ };
+ public static void main(String[] args) {
+ Scanner sc =new Scanner(System.in);
+ int n = sc.nextInt();
+ sc.nextLine();
+ for (;n>0;n--){
+ char[] inp =sc.nextLine().toCharArray();
+ while (true) {
+ int i = 1;
+ for (; i < inp.length ; i++) {
+ int p=inp[i-1]-'0';
+ int r=inp[i]-'0';
+ if (flag[p][r]!=1) {
+ break;
+ }
+ }
+ if (i=0&&jw!=0; i--){
+ if(a[i]-'0'>0){
+ a[i] += jw;
+ jw = 0;
+ }
+ else{
+ a[i] = '9';
+ jw = -1;
+ }
+ for(int j=i+1;j mp = new LinkedHashMap<>();
+ while (sc.hasNext()){
+ String input = sc.next();
+ if (input.equals("-1"))
+ break;
+ Integer line= sc.nextInt();
+ String name = input.substring(input.lastIndexOf("\\")+1);
+ if (mp.containsKey(name+" "+line)){
+ mp.put(name+" "+line,mp.get(name+" "+line)+1);
+ }else {
+ mp.put(name+" "+line,1);
+ }
+ }
+ ArrayList> a = new ArrayList<>(mp.entrySet());
+ Collections.sort(a, new Comparator>() {
+ @Override
+ public int compare(Map.Entry o1, Map.Entry o2) {
+ int res= o1.getValue().compareTo(o2.getValue());
+ return res*-1;
+ }
+ });
+ int m=0;
+ for (Map.Entry entry:a){
+ m++;
+ if (m>8)
+ break;
+ String temp[]=entry.getKey().split(" ");
+ System.out.println(temp[0].substring(Math.max(temp[0].length()-16,0),temp[0].length())+" "+temp[1]+" "+entry.getValue());
+
+ }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/acm/Solution.java b/jlh/src/main/java/com/jlh/viewer/acm/Solution.java
new file mode 100644
index 0000000000000000000000000000000000000000..638708bf61a1f812c0c9e3cddc496debd2afcbde
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/acm/Solution.java
@@ -0,0 +1,51 @@
+package com.jlh.viewer.acm;
+
+/**
+ * Created by jlh
+ * On 2017/4/12 0012.
+ */
+public class Solution {
+ /**
+ * 返回git树上两点的最近分割点
+ *
+ * @param matrix 接邻矩阵,表示git树,matrix[i][j] == '1' 当且仅当git树中第i个和第j个节点有连接,节点0为git树的跟节点
+ * @param indexA 节点A的index
+ * @param indexB 节点B的index
+ * @return 整型
+ */
+ public int getSplitNode(String[] matrix, int indexA, int indexB) {
+ boolean[] vis = new boolean[matrix.length];
+ vis[0]=true;
+ String[] resA= reslove(matrix,0,indexA,vis).split(",");
+ String[] resB=reslove(matrix,0,indexB,vis).split(",");
+ int i=0;
+ for (;i=0;j--){
+ int inp= sc.nextInt();
+ score[inp]+=j;
+ if (maxs=l1) result += dp[i];
+ }
+ System.out.println(result%1000007);
+ }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/acm/Visit.java b/jlh/src/main/java/com/jlh/viewer/acm/Visit.java
new file mode 100644
index 0000000000000000000000000000000000000000..846e35551eef6c8cf06c9be6f61d092388fe9f80
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/acm/Visit.java
@@ -0,0 +1,56 @@
+package com.jlh.viewer.acm;
+
+/**
+ * com.jlh.viewer.acm
+ * Created by ASUS on 2017/4/20.
+ * 17:23
+ */
+public class Visit {
+ public int countPath(int[][] map, int n, int m) {
+ int a1=-1,b1=-1,a2=-1,b2=-1;
+ int[][] dp=new int[n][m];
+ for (int i=0;i=0;i+=x){
+ for (int j=b1+y;y==1?j=0;j+=y){
+ if (map[i][j]==-1)
+ dp[i][j]=0;
+ else
+ dp[i][j]=dp[i-x][j]+dp[i][j-y];
+ }
+ }
+ return dp[a2][b2];
+ }
+
+ public static void main(String[] args) {
+ Visit visit = new Visit();
+ System.out.println(visit.countPath(new int[][]{{0,1,0},{2,0,0}},2,3));
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/algorithm/BubbleSort.java b/jlh/src/main/java/com/jlh/viewer/algorithm/BubbleSort.java
new file mode 100644
index 0000000000000000000000000000000000000000..862076bbed20bca9c0b7920b6a289c4d4748fd0a
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/algorithm/BubbleSort.java
@@ -0,0 +1,33 @@
+package com.jlh.viewer.algorithm;
+
+import java.util.Arrays;
+
+/**
+ * com.jlh.viewer.algorithm
+ * Created by ASUS on 2017/4/19.
+ * 9:58
+ */
+public class BubbleSort {
+ public static void sort (int []a){
+ boolean flag= true;
+ int i=a.length-1;
+ while (flag){
+ flag=false;
+ for (int j=0;j=n)
+ tree[index]=Math.max(update(index*2,left,mid,n,value),tree[index*2+1]);
+ else
+ tree[index]=Math.max(update(index*2+1,mid+1,right,n,value),tree[index*2]);
+ }
+ return tree[index];
+ }
+
+ public int query (int start,int end){
+ return query(1,1,size,start,end);
+ }
+ private int query (int index,int left,int right,int start,int end){
+ if (left>=start&&right<=end)
+ return tree[index];
+ int mid = (left+right)/2;
+ int a = 0,b=0;
+ if (start<=mid)
+ a=query(index*2,left,mid,start,end);
+ if (end>mid)
+ b=query(index*2+1,mid+1,right,start,end);
+
+ return Math.max(a,b);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/algorithm/MHeap.java b/jlh/src/main/java/com/jlh/viewer/algorithm/MHeap.java
index f6239e0de2c5e6f32318504e190c4bf0d1558b90..d8c34012a4e4dc337ae6e4a35ac8895910ff2168 100644
--- a/jlh/src/main/java/com/jlh/viewer/algorithm/MHeap.java
+++ b/jlh/src/main/java/com/jlh/viewer/algorithm/MHeap.java
@@ -1,5 +1,6 @@
package com.jlh.viewer.algorithm;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
/**
@@ -7,12 +8,10 @@ import java.lang.reflect.Array;
* On 2017/3/15 0015.
*/
public class MHeap {
- private Class type;
private T[] datas;
private int store;
- public MHeap(int size,Class type){
- this.type=type;
- datas= (T[]) Array.newInstance(type,size);
+ public MHeap(int size){
+ datas= (T[]) Array.newInstance(Comparable.class,size);
store=0;
}
public boolean push (T d){
@@ -20,7 +19,7 @@ public class MHeap {
int k=store;
datas[store++]=d;
if (k>=1) {
- adjust((k-1)/2);
+ adjust2((k-1)/2);
}
}
return false;
@@ -36,6 +35,23 @@ public class MHeap {
return null;
}
+ private void adjust2(int parent){
+ int l=parent*2+1;
+ int r=parent*2+2;
+ int index = parent;
+ if (l {
}
public static void main(String[] args) {
- MHeap mHeap = new MHeap<>(15,Integer.class);
+ MHeap mHeap = new MHeap<>(15);
mHeap.push(5);
mHeap.push(3);
mHeap.push(6);
- System.out.println(mHeap.pop());
+ mHeap.push(7);
+ mHeap.push(2);
+ mHeap.push(9);
+ while (mHeap.store>0)
+ System.out.println(mHeap.pop());
}
}
diff --git a/jlh/src/main/java/com/jlh/viewer/algorithm/MQueue.java b/jlh/src/main/java/com/jlh/viewer/algorithm/MQueue.java
index dd295d175d22a7d1cf37b0a11749cec807124ea3..4dbbb36bf97c3921561eeaed0a818a9dbfaedada 100644
--- a/jlh/src/main/java/com/jlh/viewer/algorithm/MQueue.java
+++ b/jlh/src/main/java/com/jlh/viewer/algorithm/MQueue.java
@@ -34,13 +34,11 @@ public class MQueue {
}
public boolean isEmpty(){
- return store==0?true:false;
+ return store == 0;
}
public boolean isFull(){
- if (store==datas.length)
- return true;
- return false;
+ return store == datas.length;
}
@Override
diff --git a/jlh/src/main/java/com/jlh/viewer/algorithm/MergeSort.java b/jlh/src/main/java/com/jlh/viewer/algorithm/MergeSort.java
index 89d6177e46ce95ada404dd000e1bd0d661cf12c9..69832dca607971f257de46c919f5ef2a7763185c 100644
--- a/jlh/src/main/java/com/jlh/viewer/algorithm/MergeSort.java
+++ b/jlh/src/main/java/com/jlh/viewer/algorithm/MergeSort.java
@@ -18,7 +18,7 @@ public class MergeSort {
reslove(a,first,last-1,new int[a.length]);
}
- public void reslove(int a[],int first,int last,int []temp){
+ private void reslove(int a[], int first, int last, int[] temp){
if (first {
+ private static final boolean BLACK=true;
+ private static final boolean RED=false;
+ private TreeNode root;
+ private Integer size;
+
+ public TreeBin() {
+ root=new TreeNode();
+ root.color=BLACK;
+ root.left=null;
+ root.right=null;
+ root.parent=null;
+ size=0;
+ }
+
+ public boolean push (T v){
+ TreeNode node = findNode(v);
+ node.value=v;
+ size++;
+ adjust(node);
+ return true;
+ }
+
+
+ private void adjust(TreeNode t){
+ TreeNode parent,gparent;
+ while ((parent=t.parent)!=null&&parent.color==RED){
+ gparent=parent.parent;
+ //父节点是祖父节点的左节点
+ if (parent==gparent.left){
+ TreeNode uncle= gparent.right;
+ //1. 叔叔节点是黑色的 节点是父节点的左子树
+ if((uncle==null||uncle.color==BLACK)&&(t==parent.left)){
+ parent.color=BLACK;
+ gparent.color=RED;
+ rightRotate(gparent);
+ }
+ // 叔叔是黑色的 节点是父节点的右子树
+ else if ((uncle==null||uncle.color==BLACK)&&t==parent.right){
+ t.color=BLACK;
+ gparent.color=RED;
+ leftRotate(parent);
+ rightRotate(gparent);
+ }
+
+ }else {//父节点是祖父节点的右节点
+ TreeNode uncle= gparent.left;
+ // 叔叔是黑色的 节点是父节点的右子树
+ if((uncle==null||uncle.color==BLACK)&&(t==parent.right)){
+ parent.color=BLACK;
+ gparent.color=RED;
+ leftRotate(gparent);
+ }
+ // 叔叔是黑色的 节点是父节点的左子树
+ else if ((uncle==null||uncle.color==BLACK)&&t==parent.left){
+ t.color=BLACK;
+ gparent.color=RED;
+ rightRotate(parent);
+ leftRotate(gparent);
+ }
+
+ }
+ }
+ root.color=BLACK;
+ }
+
+ private void leftRotate(TreeNode x){
+ // 设置x的右孩子为y
+ TreeNode y = x.right;
+
+ // 将 “y的左孩子” 设为 “x的右孩子”;
+ // 如果y的左孩子非空,将 “x” 设为 “y的左孩子的父亲”
+ x.right = y.left;
+ if (y.left != null)
+ y.left.parent = x;
+
+ // 将 “x的父亲” 设为 “y的父亲”
+ y.parent = x.parent;
+
+ if (x.parent == null) {
+ this.root = y; // 如果 “x的父亲” 是空节点,则将y设为根节点
+ } else {
+ if (x.parent.left == x)
+ x.parent.left = y; // 如果 x是它父节点的左孩子,则将y设为“x的父节点的左孩子”
+ else
+ x.parent.right = y; // 如果 x是它父节点的左孩子,则将y设为“x的父节点的左孩子”
+ }
+
+ // 将 “x” 设为 “y的左孩子”
+ y.left = x;
+ // 将 “x的父节点” 设为 “y”
+ x.parent = y;
+ }
+
+ private void rightRotate(TreeNode y){
+ TreeNode x= y.left;
+ y.left=x.right;
+ if (x.right!=null){
+ x.right.parent=y;
+ }
+ x.parent=y.parent;
+ if (y.parent==null){
+ root=x;
+ }else {
+ if (y.parent.left==y)
+ y.parent.left=x;
+ else
+ y.parent.right=x;
+ }
+ x.right=y;
+ y.parent=x;
+ }
+
+ private TreeNode findNode(T v){
+ if (size.equals(0))
+ return root;
+ TreeNode p = root;
+ while (true){
+ if (p.value.compareTo(v)>0&&p.left!=null)
+ p=p.left;
+ else if (p.value.compareTo(v)>0&&p.left==null){
+ p.left=createChild(p);
+ return p.left;
+ }
+ else if (p.value.compareTo(v)<=0&&p.right!=null)
+ p=p.right;
+ else if (p.value.compareTo(v)<=0&&p.right==null){
+ p.right=createChild(p);
+ return p.right;
+ }
+
+ }
+ }
+
+ private TreeNode createChild(TreeNode p){
+ TreeNode child= new TreeNode();
+ child.left=null;
+ child.right=null;
+ child.parent=p;
+ return child;
+ }
+
+
+ public static void main(String[] args) {
+ TreeBin treeBin = new TreeBin<>();
+ treeBin.push(2);
+ treeBin.push(1);
+ treeBin.push(3);
+ treeBin.push(4);
+ System.out.println(treeBin);
+ }
+ private static class TreeNode {
+ /**
+ * 节点的颜色,false代表红色,true代表黑色
+ */
+ private Boolean color =RED ;
+ /**
+ * 节点值
+ */
+ private K value;
+ /**
+ * 左节点
+ */
+ private TreeNode left;
+ /**
+ * 右节点
+ */
+ private TreeNode right;
+ /**
+ * 父节点
+ */
+ private TreeNode parent;
+
+ }
+
+ @Override
+ public String toString() {
+ return "TreeBin{" +
+ "root=" + root +
+ ", size=" + size +
+ '}';
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/algorithm/TreeIntroduce.java b/jlh/src/main/java/com/jlh/viewer/algorithm/TreeIntroduce.java
index d8305e4d668784ec69f7b4b60a5b73ccb0e6075d..be12c32beca126f5f2f1bf66437fc71f1ee10ea9 100644
--- a/jlh/src/main/java/com/jlh/viewer/algorithm/TreeIntroduce.java
+++ b/jlh/src/main/java/com/jlh/viewer/algorithm/TreeIntroduce.java
@@ -16,6 +16,9 @@ public class TreeIntroduce {
* 完全二叉树:k-1层 满节点 ,k层从左往右填满
* 满二叉树:所有节点都满 ,第K层 节点数量 2^(k-1) 总结点数量 2^k-1
* 堆:一般就是大小堆,是特殊的完全二叉树,节点值大于或小于子节点
+ * K叉树总结点个数=kn*n+ k(n-1)*(n-1).... k2*2 +k1+1 kn 为n度的节点个数
+ * 线索二叉树 ,记录该节点按中序遍历时候的前驱和后继,一般右子树为空就用了记录后继,左为空记录前驱
+ *
*
*
* 根据前序和中序还原二叉树:前序遍历第一个一定是树的根节点,然后从中序中找到根节点位置,从左填起
diff --git a/jlh/src/main/java/com/jlh/viewer/base64/Base64Utils.java b/jlh/src/main/java/com/jlh/viewer/base64/Base64Utils.java
new file mode 100644
index 0000000000000000000000000000000000000000..cf5987cbf142b7f2ef8868f41ad983ad3912776c
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/base64/Base64Utils.java
@@ -0,0 +1,16 @@
+package com.jlh.viewer.base64;
+
+import java.util.Base64;
+
+/**
+ * Created by jlh
+ * On 2017/4/5 0005.
+ */
+class Base64Utils {
+ static String encode(byte[] context){
+ return Base64.getEncoder().encodeToString(context);
+ }
+ static byte[] decode(String context){
+ return Base64.getDecoder().decode(context);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/base64/Main.java b/jlh/src/main/java/com/jlh/viewer/base64/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..015e29f46babb9acfec61f399be5ac581cfd859d
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/base64/Main.java
@@ -0,0 +1,71 @@
+package com.jlh.viewer.base64;
+
+import java.io.*;
+
+/**
+ * Created by jlh
+ * On 2017/4/5 0005.
+ */
+public class Main {
+ public static void main(String[] args) {
+ byte[] data = null;
+ byte[] buffer= new byte[1024];
+ File file = new File("D:\\test\\orignal.jpg");
+ try (FileInputStream in = new FileInputStream(file);ByteArrayOutputStream byteArrayOutputStream= new ByteArrayOutputStream(1024)){
+ int size;
+ while (-1 != (size = in.read(buffer))){
+ byteArrayOutputStream.write(buffer,0,size);
+ }
+ data=byteArrayOutputStream.toByteArray();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ String encode= Base64Utils.encode(data);
+ //存储
+
+ File codeFile = new File("D:\\test\\code.txt");
+ if (codeFile.exists())
+ codeFile.delete();
+ try {
+ codeFile.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try(FileWriter fileWriter = new FileWriter(codeFile)) {
+ fileWriter.write(encode);
+ fileWriter.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ //输出解密图片
+ File decodeFile = new File("D:\\test\\decode.jpg");
+ if (decodeFile.exists())
+ decodeFile.delete();
+ try {
+ decodeFile.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ String codeContext= null;
+ try (FileReader reader = new FileReader(codeFile)){
+ StringBuilder stringBuffer =new StringBuilder();
+ char[] buf = new char[1024];
+ while (-1 != reader.read(buf)){
+ stringBuffer.append(buf);
+ }
+ codeContext=stringBuffer.toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ byte[] decodeByte=Base64Utils.decode(codeContext);
+ try (FileOutputStream out =new FileOutputStream(decodeFile)) {
+ out.write(decodeByte);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/collections/ConcurrentHashMapTestList.java b/jlh/src/main/java/com/jlh/viewer/collections/ConcurrentHashMapTestList.java
new file mode 100644
index 0000000000000000000000000000000000000000..3d77a68599d5b0cd4a81450cbfcbbec4722ecb27
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/collections/ConcurrentHashMapTestList.java
@@ -0,0 +1,37 @@
+package com.jlh.viewer.collections;
+
+import java.util.Hashtable;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Created by jlh
+ * On 2017/3/15 0015.
+ */
+public class ConcurrentHashMapTestList {
+ public static void main(String[] args) {
+
+ /*
+ *
+ * 并发三大特性:
+ * 原子性
+ * 可见性,
+ * 重排序
+ *
+ * JDK1.8 以下
+ * concurrent 每次访问只对某一个segment加锁 使用lock 来实现,
+ * 因此其他线程访问不同segment 不会阻塞,性能高
+ * segment --> tb1 -->tb2
+ * segment --> tb1
+ * segment -->
+ * JDK1.8
+ * concurrent Treebin对象,代替treenode ,包涵锁的功能,链表长了以后使用treebin对象,
+ * 也就是代替了树的根节点,其余节点为treenode
+ * 对段(segment)的锁定是通过 synchronized 来完成 (写操作) 读操作通过cas完成
+ * hashtable是对整个操作进行 synchronized 所以,每次操作都会锁整个对象,性能差
+ * */
+ Hashtable hashtable = new Hashtable();
+ ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
+ for (int i=0;i<14;i++)
+ concurrentHashMap.put("key_"+i,"huaizuo_" + i);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/collections/HashMapTestList.java b/jlh/src/main/java/com/jlh/viewer/collections/HashMapTestList.java
index 595058218b1728ba3be8f8f51a192bcba8872611..08afe8ef383e934d274438b0675582b64dee6417 100644
--- a/jlh/src/main/java/com/jlh/viewer/collections/HashMapTestList.java
+++ b/jlh/src/main/java/com/jlh/viewer/collections/HashMapTestList.java
@@ -9,6 +9,11 @@ import java.util.HashMap;
*/
public class HashMapTestList {
public static void main(String[] args) {
+ /*
+ * JDK 1.8
+ * concurrent 不再仅仅是数组+链表,而是数组+链表+红黑树 链表大于8自动转为红黑树
+ */
+ //linkedHashMap 与hashmap的区别是,增加了记录插入顺序,遍历时可以按插入顺序遍历
// 负载0.75 默认16capacity Entry bucket[] ---> Entry-->Entry--->....Entry 数组+链表 链表地址法
// threshold(临界值) = 负载*capacity iterator 保证快速失败--> volatile modcount 保持可见性 新增和删除操作+1 修改不变
HashMap map=new HashMap<>();
diff --git a/jlh/src/main/java/com/jlh/viewer/dynaic.java b/jlh/src/main/java/com/jlh/viewer/dynaic.java
new file mode 100644
index 0000000000000000000000000000000000000000..fdcb61b5d9da32488062736498780c4aab8f9611
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/dynaic.java
@@ -0,0 +1,42 @@
+package com.jlh.viewer;
+
+/**
+ * com.jlh.viewer
+ * Created by ASUS on 2017/4/19.
+ * 16:39
+ */
+public class dynaic {
+ public static void main(String[] args) {
+ Son s = new Son();
+ System.out.println(s.a);
+ System.out.println(((Father)s).a);
+ System.out.println(s.b);
+ System.out.println(((Father)s).b);
+ System.out.println(s.get());
+ System.out.println(((Father)s).get());
+ s.work();
+ ((Father)s).work();
+ }
+ static class Father {
+ int a=1;
+ static int b=1;
+ public int get(){
+ return a;
+ }
+ public static void work(){
+ System.out.println("father");
+ }
+ }
+
+ static class Son extends Father{
+ int a=2;
+ static int b=2;
+ public int get(){
+ return a;
+ }
+ public static void work(){
+ System.out.println("son");
+ }
+ }
+
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/exception/ExceptionTest.java b/jlh/src/main/java/com/jlh/viewer/exception/ExceptionTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..328d78d33016f41f2f33e453cca925c58c9335d8
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/exception/ExceptionTest.java
@@ -0,0 +1,36 @@
+package com.jlh.viewer.exception;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by jlh
+ * On 2017/4/7 0007.
+ */
+public class ExceptionTest {
+ private static int x = 100;
+
+ private static void add() {
+ }
+
+ public static void main(String[] args) {
+
+ List list = Arrays.asList(1, 2, 3, 4);
+ list.forEach(System.out::println);
+ ExceptionTest exceptionTest = new ExceptionTest();
+ try {
+ throw new IOException("123");
+ } catch (IOException e) {
+ System.out.println("IOE");
+ } catch (Exception e) {
+ System.out.println("E");
+ }
+ }
+
+
+ private class ass {
+ void add() {
+ }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/genericity/ExtendSuperTest.java b/jlh/src/main/java/com/jlh/viewer/genericity/ExtendSuperTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..a1012088c303118c932b83e9e951c9a5978b54ee
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/genericity/ExtendSuperTest.java
@@ -0,0 +1,31 @@
+package com.jlh.viewer.genericity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * com.jlh.viewer.genericity
+ * Created by ASUS on 2017/4/28.
+ * 8:58
+ */
+public class ExtendSuperTest {
+ public static class A{
+
+ }
+ public static class B extends A{}
+ public static class C extends B{}
+
+
+ public static class D {
+ T t;
+ }
+
+
+ public static void main(String[] args) {
+ D d = new D();
+ D d1 = new D();
+// D d2 = new D();
+ List super B> a =new ArrayList<>();
+ a.add(new C());
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/genericity/Main.java b/jlh/src/main/java/com/jlh/viewer/genericity/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..a84d4e03d104c4d17327a5b82d8058dfc71d47ed
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/genericity/Main.java
@@ -0,0 +1,36 @@
+package com.jlh.viewer.genericity;
+
+/**
+ * com.jlh.viewer.genericity
+ * Created by ASUS on 2017/4/23.
+ * 9:46
+ */
+public class Main {
+ public static class Stack {
+ private int size;
+ private int top=-1;
+ private Object[] datas;
+
+ public Stack(int size) {
+ this.size=size;
+ datas=new Object[size];
+ }
+ public T pop(){
+ return (top >= 0) ? (T) datas[top--] : null;
+ }
+ public void push (T v){
+ if (top+1 stack =new Stack<>(3);
+ stack.push(2);
+ System.out.println(stack.pop());
+ stack.push(1);
+ stack.push(3);
+ stack.push(4);
+ stack.push(5);
+ System.out.println(1);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/gsonFomartTest.java b/jlh/src/main/java/com/jlh/viewer/gsonFomartTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0ccfaea436fb800215bf3363619fbd0222cc9d2f
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/gsonFomartTest.java
@@ -0,0 +1,119 @@
+package com.jlh.viewer;
+
+/**
+ * Created by jlh
+ * On 2017/4/11 0011.
+ */
+public class gsonFomartTest {
+
+
+ /**
+ * reason : 成功1
+ * result : {"jobid":"2015120913503797592","realname":"商世界","bankcard":"6259656360701234","idcard":"310329198103050011","mobile":"18912341234","res":"2","message":"认证信息不匹配"}
+ * error_code : 0
+ */
+
+ private String reason;
+ private ResultBean result;
+ private int error_code;
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public ResultBean getResult() {
+ return result;
+ }
+
+ public void setResult(ResultBean result) {
+ this.result = result;
+ }
+
+ public int getError_code() {
+ return error_code;
+ }
+
+ public void setError_code(int error_code) {
+ this.error_code = error_code;
+ }
+
+ public static class ResultBean {
+ /**
+ * jobid : 2015120913503797592
+ * realname : 商世界
+ * bankcard : 6259656360701234
+ * idcard : 310329198103050011
+ * mobile : 18912341234
+ * res : 2
+ * message : 认证信息不匹配
+ */
+
+ private String jobid;
+ private String realname;
+ private String bankcard;
+ private String idcard;
+ private String mobile;
+ private String res;
+ private String message;
+
+ public String getJobid() {
+ return jobid;
+ }
+
+ public void setJobid(String jobid) {
+ this.jobid = jobid;
+ }
+
+ public String getRealname() {
+ return realname;
+ }
+
+ public void setRealname(String realname) {
+ this.realname = realname;
+ }
+
+ public String getBankcard() {
+ return bankcard;
+ }
+
+ public void setBankcard(String bankcard) {
+ this.bankcard = bankcard;
+ }
+
+ public String getIdcard() {
+ return idcard;
+ }
+
+ public void setIdcard(String idcard) {
+ this.idcard = idcard;
+ }
+
+ public String getMobile() {
+ return mobile;
+ }
+
+ public void setMobile(String mobile) {
+ this.mobile = mobile;
+ }
+
+ public String getRes() {
+ return res;
+ }
+
+ public void setRes(String res) {
+ this.res = res;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/http/httpsUtils.java b/jlh/src/main/java/com/jlh/viewer/http/httpsUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..7c3485136c242bce058e0b456597e5933bd9a4f6
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/http/httpsUtils.java
@@ -0,0 +1,8 @@
+package com.jlh.viewer.http;
+
+/**
+ * Created by jlh
+ * On 2017/3/29 0029.
+ */
+public class httpsUtils {
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/interfaceT/Test.java b/jlh/src/main/java/com/jlh/viewer/interfaceT/Test.java
new file mode 100644
index 0000000000000000000000000000000000000000..1cf2b250efc3d59b4222016fe7a1d178fe8e38f5
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/interfaceT/Test.java
@@ -0,0 +1,13 @@
+package com.jlh.viewer.interfaceT;
+
+/**
+ * com.jlh.viewer.interfaceT
+ * Created by ASUS on 2017/3/25.
+ * 13:59
+ */
+public interface Test {
+ abstract void test();
+ static String pr(){
+ return "2333";
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/lambda/Main.java b/jlh/src/main/java/com/jlh/viewer/lambda/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..d40806c68cb5cbf80faea44d03910b712014e3a1
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/lambda/Main.java
@@ -0,0 +1,24 @@
+package com.jlh.viewer.lambda;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+/**
+ * Created by jlh
+ * On 2017/4/11 0011.
+ */
+public class Main {
+ public static void main(String[] args) {
+ String []key ={"k1","k2","k3","k4","k5"};
+ List list= Arrays.asList(1,2,3,4,5);
+ list.stream().collect(
+ (Supplier>) ArrayList::new,
+ (integers, integer) -> integers.add(integer),
+ List::addAll
+ ).forEach(System.out::print);
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/out.txt b/jlh/src/main/java/com/jlh/viewer/out.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0ccfaea436fb800215bf3363619fbd0222cc9d2f
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/out.txt
@@ -0,0 +1,119 @@
+package com.jlh.viewer;
+
+/**
+ * Created by jlh
+ * On 2017/4/11 0011.
+ */
+public class gsonFomartTest {
+
+
+ /**
+ * reason : 成功1
+ * result : {"jobid":"2015120913503797592","realname":"商世界","bankcard":"6259656360701234","idcard":"310329198103050011","mobile":"18912341234","res":"2","message":"认证信息不匹配"}
+ * error_code : 0
+ */
+
+ private String reason;
+ private ResultBean result;
+ private int error_code;
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public ResultBean getResult() {
+ return result;
+ }
+
+ public void setResult(ResultBean result) {
+ this.result = result;
+ }
+
+ public int getError_code() {
+ return error_code;
+ }
+
+ public void setError_code(int error_code) {
+ this.error_code = error_code;
+ }
+
+ public static class ResultBean {
+ /**
+ * jobid : 2015120913503797592
+ * realname : 商世界
+ * bankcard : 6259656360701234
+ * idcard : 310329198103050011
+ * mobile : 18912341234
+ * res : 2
+ * message : 认证信息不匹配
+ */
+
+ private String jobid;
+ private String realname;
+ private String bankcard;
+ private String idcard;
+ private String mobile;
+ private String res;
+ private String message;
+
+ public String getJobid() {
+ return jobid;
+ }
+
+ public void setJobid(String jobid) {
+ this.jobid = jobid;
+ }
+
+ public String getRealname() {
+ return realname;
+ }
+
+ public void setRealname(String realname) {
+ this.realname = realname;
+ }
+
+ public String getBankcard() {
+ return bankcard;
+ }
+
+ public void setBankcard(String bankcard) {
+ this.bankcard = bankcard;
+ }
+
+ public String getIdcard() {
+ return idcard;
+ }
+
+ public void setIdcard(String idcard) {
+ this.idcard = idcard;
+ }
+
+ public String getMobile() {
+ return mobile;
+ }
+
+ public void setMobile(String mobile) {
+ this.mobile = mobile;
+ }
+
+ public String getRes() {
+ return res;
+ }
+
+ public void setRes(String res) {
+ this.res = res;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/thread/ReentrantLockTest.java b/jlh/src/main/java/com/jlh/viewer/thread/ReentrantLockTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..08d43c77f0a45eeb305804b8b16e8b10fc0aec1e
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/thread/ReentrantLockTest.java
@@ -0,0 +1,12 @@
+package com.jlh.viewer.thread;
+
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * com.jlh.viewer.thread
+ * Created by ASUS on 2017/4/21.
+ * 14:48
+ */
+public class ReentrantLockTest {
+ private ReentrantLock lock = new ReentrantLock();
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/thread/ThreadPool.java b/jlh/src/main/java/com/jlh/viewer/thread/ThreadPool.java
new file mode 100644
index 0000000000000000000000000000000000000000..bad6554a17462fb0064c22698ce6875f29e41270
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/thread/ThreadPool.java
@@ -0,0 +1,18 @@
+package com.jlh.viewer.thread;
+
+import java.util.concurrent.*;
+
+/**
+ * com.jlh.viewer.thread
+ * Created by ASUS on 2017/4/25.
+ * 13:36
+ */
+public class ThreadPool {
+ public static void main(String[] args) {
+ ExecutorService executorService = new ThreadPoolExecutor(5, 10,
+ 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), (r, executor) -> {
+ executor.getQueue().poll();
+ executor.getQueue().offer(r);
+ });
+ }
+}
diff --git a/jlh/src/main/java/com/jlh/viewer/thread/ThreadWait.java b/jlh/src/main/java/com/jlh/viewer/thread/ThreadWait.java
new file mode 100644
index 0000000000000000000000000000000000000000..a2b7e4428c14ca01d17e9d51a65aab07c6e8059a
--- /dev/null
+++ b/jlh/src/main/java/com/jlh/viewer/thread/ThreadWait.java
@@ -0,0 +1,36 @@
+package com.jlh.viewer.thread;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by jlh
+ * On 2017/4/6 0006.
+ */
+public class ThreadWait {
+ private static Thread th1,th2;
+ private static int flag=0;
+ public static void main(String[] args) throws InterruptedException {
+
+ th1=new Thread(()->{
+ for(;;){
+ synchronized (th1) {
+ System.out.println("th1");
+ try {
+ if (flag==0)
+ th1.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ th1.start();
+ TimeUnit.SECONDS.sleep(2);
+ synchronized (th1){
+ th1.notifyAll();
+ TimeUnit.SECONDS.sleep(2);
+ System.out.println(11111);
+ }
+
+ }
+}
diff --git a/jlh/src/main/java/module-info.java b/jlh/src/main/java/module-info.java
new file mode 100644
index 0000000000000000000000000000000000000000..eba005ad43985c18d383834f2bff11c37b691353
--- /dev/null
+++ b/jlh/src/main/java/module-info.java
@@ -0,0 +1,9 @@
+/**
+ * Created by jlh
+ * On 2017/3/31 0031.
+ *
+ */
+//module jlh {
+// requires jdk.incubator.httpclient;
+// requires netty.all;
+//}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 39e3c3e569461dc15eceefd2e28d46bab1561257..772942d9d3315b63963fe77447d53a6d28c71e8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,6 +22,7 @@
jlh
+ xx
diff --git a/xx/pom.xml b/xx/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..67038ada160fcdfd1682315237ecedc604d84d5a
--- /dev/null
+++ b/xx/pom.xml
@@ -0,0 +1,30 @@
+
+
+
+ test
+ com.xx
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ xx
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xx/src/main/java/com/xx/base/string/StringBase.java b/xx/src/main/java/com/xx/base/string/StringBase.java
index fb59790aff9c0e1a2fa08b0087fb7e1e6bac8e25..cab9353d0ff95f30b0b774570320f8f588e2e486 100644
--- a/xx/src/main/java/com/xx/base/string/StringBase.java
+++ b/xx/src/main/java/com/xx/base/string/StringBase.java
@@ -1,4 +1,4 @@
-package java.com.xx.base.string;
+package com.xx.base.string;
/**
* author: XiongXin