All pastes #673346 Raw Edit

NullPointer error :/

public text v1 · immutable
#673346 ·published 2007-08-28 10:18 UTC
rendered paste body
import java.io.*;
import javax.swing.*;

public class Patch {
	
	public static void main(String[] args) throws IOException {
		try {
			BufferedReader inStream = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Initilizing and grabbing content to copy...");
			String src = ".//test.txt";
			File source = new File(src);
			System.out.println("Done.");
			System.out.println("Please specify your tibia directory. It's usually in program folders.");
			String dir = inStream.readLine();
			
			if(dir.equals("")) {
				System.out.println("Invalid directory.");
			}
			File destination = new File(dir);
			if(!destination.exists()) {
				System.out.println("Mentioned directory does not exist.");
			}
			else if(destination.exists()) {
				copyFile(source, destination);
			}
		} catch(IOException e) {
			System.out.println("Error.");
			e.printStackTrace();
		}
	}
	
	public static void copyFile(File source, File dest) throws IOException {
		if(!dest.exists()) {
			dest.createNewFile();
		}
		InputStream in = null;
		OutputStream out = null;
		try {
			in = new FileInputStream(source);
			out = new FileOutputStream(dest);
			byte[] buf = new byte[1024];
			int len;
			while((len = in.read(buf)) > 0) {
				out.write(buf, 0, len);
			}
		}
		finally {
			in.close();
            out.close();
        }
	}
}		//fix it.