gpt4 book ai didi

kotlin - kscript : How to get directory of current file?

转载 作者:行者123 更新时间:2023-12-04 14:26:50 27 4
gpt4 key购买 nike

有没有办法在 kotlin 脚本中获取当前脚本位置的目录?

我可以在 bash 中实现这一点

 dirname $0

或者
# Absolute path to this script. /home/user/bin/foo.sh
SCRIPT=$(readlink -f $0)
# Absolute path this script is in. /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`

最佳答案

您可以使用:File(".")并且不要忘记import java.io.File

关于kotlin - kscript : How to get directory of current file?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61873733/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com