在Java中,我可以使用以下代码:
public class Ex {
public static void main(String [ ] args) {
String path = Ex.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8");
}
}
但是在 Kotlin 中,主函数是在类之外定义的。我如何获取它的当前文件名?