⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filecopier.java

📁 java编写的监控一个文件夹里面有没有新的excel文件放入
💻 JAVA
字号:
package com.justin.util;

import java.io.*;
import java.nio.*;
import java.nio.channels.*;

public class FileCopier {
	public static void copy(String inFilePath, String outFilePath)
			throws IOException {
		FileInputStream fin = null;
		RandomAccessFile fout = null;
		try {
			fin = new FileInputStream(inFilePath);
			fout = new RandomAccessFile(outFilePath, "rw");

			FileChannel in = fin.getChannel();
			FileChannel out = fout.getChannel();

			MappedByteBuffer input = in.map(FileChannel.MapMode.READ_ONLY, 0,
					in.size());
			MappedByteBuffer output = out.map(FileChannel.MapMode.READ_WRITE,
					0, in.size());

			output.put(input);
		} finally {
			try {
				if (fin != null)
					fin.close();
			} catch (IOException ex) {
			}
			try {
				if (fout != null)
					fout.close();
			} catch (IOException ex) {
			}
		}
	}

	public static void main(String[] args) {
		try {
			copy("D:\\ExcelFile\\test1.xls", "E:\\xu.xls");
			System.out.println("successful");
		}
		catch (IOException ex){
			System.err.println(ex);
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -