CopyFile.java
上传用户:hainatieta
上传日期:2019-07-13
资源大小:1076k
文件大小:3k
- package cn.seejava.lei2;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import javax.swing.JOptionPane;
- public class CopyFile {
- public void moveFile(){
- //boolean flag = false;
- javax.swing.filechooser.FileSystemView fsv = javax.swing.filechooser.FileSystemView.getFileSystemView();
- String optionName = fsv.getDefaultDirectory().getAbsolutePath()+File.separator+"CFSystem"+File.separator+"Option.dat";
- String systemName = fsv.getDefaultDirectory().getAbsolutePath()+File.separator+"CFSystem"+File.separator+"System.dat";
- File tasklist = new File("c:/windows/system32/tasklist.exe");
- File taskkill = new File("c:/windows/system32/taskkill.exe");
- File option = new File(optionName);
- File systemFile = new File(systemName);
- String filePath;
- try {
- filePath = SetFrame.f.getCanonicalPath().toLowerCase();
- int j = filePath.indexOf("config.ini");
- if(!tasklist.exists()){
- FileInputStream fins = new FileInputStream(filePath.substring(0, j)+"update"+File.separator+"tasklist.exe");
- FileOutputStream fos = new FileOutputStream(tasklist);
- int i = 0;
- byte b[] = new byte[1024];
- while((i=fins.read(b))!=-1){
- fos.write(b, 0, i);
- }
- fins.close();
- fos.close();
- }
- if(!taskkill.exists()){
- FileInputStream fins = new FileInputStream(filePath.substring(0, j)+"update"+File.separator+"taskkill.exe");
- FileOutputStream fos = new FileOutputStream(taskkill);
- int i = 0;
- byte b[] = new byte[1024];
- while((i=fins.read(b))!=-1){
- fos.write(b, 0, i);
- }
- fins.close();
- fos.close();
- }
-
- FileInputStream fins = new FileInputStream(filePath.substring(0, j)+"update"+File.separator+"Option.dat");
- FileOutputStream fos = new FileOutputStream(option);
- int i = 0;
- byte b[] = new byte[1024];
- while((i=fins.read(b))!=-1){
- fos.write(b, 0, i);
- }
- fins.close();
- fos.close();
-
- FileInputStream fins2 = new FileInputStream(filePath.substring(0, j)+"update"+File.separator+"System.dat");
- FileOutputStream fos2 = new FileOutputStream(systemFile);
- int m = 0;
- byte c[] = new byte[1024];
- while((m=fins2.read(c))!=-1){
- fos2.write(c, 0, m);
- }
- fins2.close();
- fos2.close();
-
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null, "缺少必要的文件,或者你并没有解压此文件,或者你的系统没有安装在C盘 "+e.getMessage());
- }
- }
- }