Skip to content

Instantly share code, notes, and snippets.

View free_copy_on_segmentfault.js
// ==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==
View HeapSort.java
import java.util.Arrays;
public class HeapSort {
public HeapSort() {
}
public static void heapSort(int[] arr) {
@ksharpdabu
ksharpdabu / MultiEchoServerNIO.java
Created Jun 21, 2016
java使用NIO实现EchoServer
View MultiEchoServerNIO.java
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 Jun 21, 2016
java使用NIO读取中文乱码的解决办法
View TestFileChannel.java
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 Jun 20, 2016
多线中的生产消费者模式
View Client.java
/**
* 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);