Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    private static void movefile(String srcPath, String dstPath) throws IOException {
        File srcFile = new File(srcPath);
        File dstFile = new File(dstPath);

        if (srcFile.exists()) {
            FileInputStream inputStream = new FileInputStream(srcFile);
            FileOutputStream outputStream = new FileOutputStream(dstFile);
            byte[] bytes = new byte[1024];
            int reads = 0;
            while ((reads = inputStream.read(bytes)) != -1) {
                outputStream.write(bytes, 0, reads);
            }
            srcFile.delete();
        }

    }
}