1. try catch finally

//java
try {
	return Integer.parseInt(str);
} catch (NumberFormatException e) {
	throw new IllegalArgumentException("")
}

//kotlin
try {
	return str.toInt()
} catch (e: NumberFormatException) {
	throw IllegalArgumentException("")
}

2. Checked Exception과 Unchecked Exception

//java
public void readFile() throws IOException {
	File currentFile = new File(".");
	File file = new File(currentFile.getAbsolutePath());
	BufferedReader reader = new BufferedReader(new FileReader(file));
	System.out.println(reader.readline());
	reader.close();
}

//kotlin
fun readFile() {
	val currentFile = File(".")
	val file = File(currentFile.getAbsolutePath())
	val reader = new BufferedReader(FileReader(file))
	println(reader.readline())
	reader.close()
}

3. try with resources

//java
public void readFile (String path) throws IOException{
	try (BufferedReader reader = new BufferedReader(new FileReader(path)) {
		System.out.println(reader.readLine());
	}
}

// kotlin
fun readFile(path : String) {
	BufferedReader(FileReader(path)).use {reader ->
		println(reader.readLine())
	}
}