2014年1月3日
摘要: private static void nioTransferCopy(File source, File target) { FileChannel in = null; FileChannel out = null; FileInputStream inStream = null; FileOutputStream outStream = null; try { inStream = new FileInputStream(source); outStream = new FileOutputStream(... 阅读全文
posted @ 2014-01-03 17:16 九哥分享职业心得 阅读(207) 评论(0) 推荐(0) 编辑
摘要: File类的总结:1.文件和文件夹的创建2.文件的读取3.文件的写入4.文件的复制(字符流、字节流、处理流)5.以图片地址下载图片---------------------相关函数(boolean) mkdir() 创建此抽象路径名指定的目录(boolean) mkdirs() 创建此抽象路径名指定的目录,包括所有必需但不存在的父目录。(boolean) delete() 删除此抽象路径名表示的文件或目录(boolean) createNewFile() 当不存在此路径名指定名称的文件时,创建一个新的空文件。创建文件public static void NewFile(String pathS 阅读全文
posted @ 2014-01-03 17:04 九哥分享职业心得 阅读(168) 评论(0) 推荐(0) 编辑
摘要: import java.io.File;/***文件综合使用示例*/public class AdvanceFileDemo { public static void main(String[] args) { File f = new File("D:\\atest"); printAllFile(f); File f1 = new File(D":\\test"); deleteAll(f1); } /** *打印f路径下所有的文件和文件夹 * @param f文件对象 */ public static void printAllFile(File 阅读全文
posted @ 2014-01-03 16:29 九哥分享职业心得 阅读(197) 评论(0) 推荐(0) 编辑
摘要: import java.io.File;import java.util.ArrayList;public class FileSystem1 { private static ArrayList filelist = new ArrayList(); public static void main(String[] args) { long a = System.currentTimeMillis(); refreshFileList("c:\\java"); System.out.println(System.... 阅读全文
posted @ 2014-01-03 16:27 九哥分享职业心得 阅读(190) 评论(0) 推荐(0) 编辑
  2013年12月13日
摘要: /** * * 改进后的归并排序: * */ public class ImprovedMergeSort { private static final int THRESHOLD = 10; public void sort(int[] data) { int[] temp = new int[data.length]; mergeSort(data, temp, 0, data.length - 1); } private void mergeSort(int[] data, int[] ... 阅读全文
posted @ 2013-12-13 17:34 九哥分享职业心得 阅读(258) 评论(0) 推荐(0) 编辑
摘要: /** * * 堆排序: * */ public class HeapSort { public void sort(int[] data) { MaxHeap h = new MaxHeap(); h.init(data); for (int i = 0; i queue[j]) // 不用交换 break; swap(queue, j, k); k = j; } ... 阅读全文
posted @ 2013-12-13 17:32 九哥分享职业心得 阅读(170) 评论(0) 推荐(0) 编辑
摘要: public class BubbleSort { public void sort(int[] data) { for (int i = 0; i i; j--) { if (data[j] < data[j - 1]) { swap(data, j, j - 1); } } } } private void swap(int[] data, int i, int j) { ... 阅读全文
posted @ 2013-12-13 17:31 九哥分享职业心得 阅读(110) 评论(0) 推荐(0) 编辑
摘要: /** * 改进后的快速排序: * */ public class ImprovedQuickSort { private static int MAX_STACK_SIZE = 4096; private static int THRESHOLD = 10; public void sort(int[] data) { int[] stack = new int[MAX_STACK_SIZE]; int top = -1; int pivot; int pivotInd... 阅读全文
posted @ 2013-12-13 17:27 九哥分享职业心得 阅读(101) 评论(0) 推荐(0) 编辑
摘要: /** * 插入排序: * */ public class InsertSort { public void sort(int[] data) { for (int i = 1; i 0) && (data[j] < data[j - 1]); j--) { swap(data, j, j - 1); } } } private void swap(int[] data, int i, int j) { int temp =... 阅读全文
posted @ 2013-12-13 17:23 九哥分享职业心得 阅读(144) 评论(0) 推荐(0) 编辑
摘要: /** * 选择排序: * */ public class SelectionSort { public void sort(int[] data) { for (int i = 0; i i; j--) { if (data[j] < data[lowIndex]) { lowIndex = j; } } swap(data, i, lowIndex); } }... 阅读全文
posted @ 2013-12-13 17:22 九哥分享职业心得 阅读(146) 评论(0) 推荐(0) 编辑