Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name free-copy-on-segmentfault
// @namespace http://tampermonkey.net/
// @version 0.1
// @description free copy on segmentfault.com
// @author Alexy
// @match https://segmentfault.com/*
// @icon https://www.google.com/s2/favicons?domain=segmentfault.com
// @grant none
// ==/UserScript==
@ksharpdabu
ksharpdabu / HeapSort.java
Created July 11, 2016 17:06
Heap Sort in Java
import java.util.Arrays;
public class HeapSort {
public HeapSort() {
}
public static void heapSort(int[] arr) {
@ksharpdabu
ksharpdabu / MultiEchoServerNIO.java
Created June 21, 2016 04:20
java使用NIO实现EchoServer
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
@ksharpdabu
ksharpdabu / TestFileChannel.java
Created June 21, 2016 04:19
java使用NIO读取中文乱码的解决办法
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
/**
@ksharpdabu
ksharpdabu / Client.java
Last active June 20, 2016 14:01
多线中的生产消费者模式
/**
* Created by AlexY on 2016/6/20.
*/
public class Client {
public static void main(String[] args) {
Sample sample = new Sample();
Producter p1 = new Producter(sample);