|
@@ -1,285 +0,0 @@
|
|
|
-package cn.com.qmth.importpaper;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.nio.ByteBuffer;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-
|
|
|
-import cn.com.qmth.S;
|
|
|
-import cn.com.qmth.multithread.ComputeConsumer;
|
|
|
-import cn.com.qmth.multithread.ComputeProducer;
|
|
|
-import cn.com.qmth.multithread.Consumer;
|
|
|
-
|
|
|
-public class Temp {
|
|
|
-
|
|
|
-// public static String[] arr = { "a", "b", "c", "d", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
|
|
|
-// "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
|
|
|
-
|
|
|
- public static String[] arr = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
-// cre();
|
|
|
- }
|
|
|
- public static byte[] decodeValue(ByteBuffer bytes) {
|
|
|
- int len = bytes.limit() - bytes.position();
|
|
|
- byte[] bytes1 = new byte[len];
|
|
|
- bytes.get(bytes1);
|
|
|
- return bytes1;
|
|
|
- }
|
|
|
- public static boolean isUtf8(byte[] line) {
|
|
|
- try {
|
|
|
- byte[] tem=new String(line,"utf-8").getBytes("utf-8");
|
|
|
- return Arrays.equals(tem, line);
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- public static void cre() {
|
|
|
- Set<String> set4 = word5();
|
|
|
- File re = new File("d:\\word.txt");
|
|
|
- if(re.exists()) {
|
|
|
- re.delete();
|
|
|
- }
|
|
|
- try {
|
|
|
- re.createNewFile();
|
|
|
- } catch (IOException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- try {
|
|
|
- FileUtils.writeLines(re, set4, "\n", true);
|
|
|
- } catch (IOException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- public static void dis() {
|
|
|
- try {
|
|
|
- File re = new File("d:\\ret.txt");
|
|
|
- File unre = new File("d:\\unret.txt");
|
|
|
- if (re.exists()) {
|
|
|
- re.delete();
|
|
|
- }
|
|
|
- if (unre.exists()) {
|
|
|
- unre.delete();
|
|
|
- }
|
|
|
- re.createNewFile();
|
|
|
- unre.createNewFile();
|
|
|
- ComputeProducer p = new ComputeProducer();
|
|
|
- p.startDispose(ComputeConsumer.class, 20, null);
|
|
|
- for (Consumer c : p.consumers) {
|
|
|
- c.disposeOnEnd(re, unre);
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (InstantiationException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按1位组合,可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:57:31
|
|
|
- */
|
|
|
- public static Set<String> word1() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- set.add(l1);
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按2位组合,可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:57:31
|
|
|
- */
|
|
|
- public static Set<String> word2() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- for (int j = 0; j < arr.length; j++) {
|
|
|
- String l2 = arr[j];
|
|
|
- String result = l1 + l2;
|
|
|
- set.add(result);
|
|
|
- }
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按3位组合,可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:57:31
|
|
|
- */
|
|
|
- public static Set<String> word3() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- for (int j = 0; j < arr.length; j++) {
|
|
|
- if (j != i) {
|
|
|
- String l2 = arr[j];
|
|
|
- for (int k = 0; k < arr.length; k++) {
|
|
|
- String l3 = arr[k];
|
|
|
- String result = l1 + l2 + l3;
|
|
|
- set.add(result);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按4位组合,可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:47:39
|
|
|
- */
|
|
|
- public static Set<String> word4() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- for (int j = 0; j < arr.length; j++) {
|
|
|
- String l2 = arr[j];
|
|
|
- for (int k = 0; k < arr.length; k++) {
|
|
|
- String l3 = arr[k];
|
|
|
- for (int m = 0; m < arr.length; m++) {
|
|
|
- String l4 = arr[m];
|
|
|
- String result = l1 + l2 + l3 + l4;
|
|
|
- set.add(result);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按4位组合,可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:47:39
|
|
|
- */
|
|
|
- public static Set<String> word5() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- for (int j = 0; j < arr.length; j++) {
|
|
|
- String l2 = arr[j];
|
|
|
- for (int k = 0; k < arr.length; k++) {
|
|
|
- String l3 = arr[k];
|
|
|
- for (int m = 0; m < arr.length; m++) {
|
|
|
- String l4 = arr[m];
|
|
|
- for (int n = 0; n < arr.length; n++) {
|
|
|
- String l5 = arr[n];
|
|
|
- String result = l1 + l2 + l3 + l4+l5;
|
|
|
- set.add(result);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按4位组合,不可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:57:31
|
|
|
- */
|
|
|
- public static Set<String> question2() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- for (int j = 0; j < arr.length; j++) {
|
|
|
- if (j != i) {
|
|
|
- String l2 = arr[j];
|
|
|
- for (int k = 0; k < arr.length; k++) {
|
|
|
- if (k != i && k != j) {
|
|
|
- String l3 = arr[k];
|
|
|
- for (int m = 0; m < arr.length; m++) {
|
|
|
- if (m != i && m != j && m != k) {
|
|
|
- String l4 = arr[m];
|
|
|
- String result = l1 + l2 + l3 + l4;
|
|
|
- set.add(result);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按5位组合,可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:47:39
|
|
|
- */
|
|
|
- public static Set<String> question3() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- for (int j = 0; j < arr.length; j++) {
|
|
|
- String l2 = arr[j];
|
|
|
- for (int k = 0; k < arr.length; k++) {
|
|
|
- String l3 = arr[k];
|
|
|
- for (int m = 0; m < arr.length; m++) {
|
|
|
- String l4 = arr[m];
|
|
|
- for (int n = 0; n < arr.length; n++) {
|
|
|
- String l5 = arr[n];
|
|
|
- String result = l1 + l2 + l3 + l4 + l5;
|
|
|
- set.add(result);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:26个纯字母不分大小写,按5位组合,不可重复。求出各种组合结果
|
|
|
- * @return
|
|
|
- * @date: 2017年11月18日 下午1:57:31
|
|
|
- */
|
|
|
- public static Set<String> question4() {
|
|
|
- Set<String> set = new HashSet<String>();
|
|
|
- for (int i = 0; i < arr.length; i++) {
|
|
|
- String l1 = arr[i];
|
|
|
- for (int j = 0; j < arr.length; j++) {
|
|
|
- if (j != i) {
|
|
|
- String l2 = arr[j];
|
|
|
- for (int k = 0; k < arr.length; k++) {
|
|
|
- if (k != i && k != j) {
|
|
|
- String l3 = arr[k];
|
|
|
- for (int m = 0; m < arr.length; m++) {
|
|
|
- if (m != i && m != j && m != k) {
|
|
|
- String l4 = arr[m];
|
|
|
- for (int n = 0; n < arr.length; n++) {
|
|
|
- if (m != i && m != j && m != k) {
|
|
|
- String l5 = arr[n];
|
|
|
- String result = l1 + l2 + l3 + l4 + l5;
|
|
|
- set.add(result);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return set;
|
|
|
- }
|
|
|
-}
|