|
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
/**
*
* @author yangqch
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throw* **ception{
FileInputStream input = new FileInputStream("name.txt");
FileChannel channel = input.getChannel();
int fileLength = (int)channel.size();
MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY,0,fileLength);
Charset charset = Charset.forName("GBK");
CharsetDecoder decoder = charset.newDecoder();
CharBuffer charBuffer = decoder.decode(buffer);
String s=charBuffer.toString();
//System.out.println(s);
File dir=new File("e:\\mp3");
File[] fs=dir.listFiles();
File m=new File("e:\\m");
for(File f:fs){
if(s.indexOf(f.getName())<0){
System.out.println(f.getName());
File n=new File("e:\\m\\"+f.getName());
f.renameTo(n);
}
}
}
} |
|