小编uty*_*ybo的帖子

如果我使用方法替换,为什么需要重新定义String?

theString如果我在此代码中使用替换方法,为什么还需要重新定义变量:

String theString = "I w@nt to h@ve the regul@r \"A\"!";
theString = theString.replace("@", "a");
System.out.println(theString);
Run Code Online (Sandbox Code Playgroud)

为什么我不能这样做:

theString.replace("@", "a");
Run Code Online (Sandbox Code Playgroud)

那就是它?

java string replace

1
推荐指数
1
解决办法
479
查看次数

mkdirs()没有使用Xubuntu创建任何文件夹

我正在尝试将文件放在目录中(The system property user.home)/.plantgrower/logs.该文件夹.myprogram不存在,我想用它的子文件夹创建它.这是我的代码:

File f = new File(System.getProperty("user.home") + File.pathSeparatorChar + ".plantgrower" + File.pathSeparatorChar + "logs");
System.out.println(f.mkdirs());
Run Code Online (Sandbox Code Playgroud)

但是,输出是,false并且不创建文件夹.我不明白为什么会这样做.

另一个奇怪的事情:我已经设置了user.home(在我的情况下/home/matthieu)每个人的写作和阅读权限,但f.canWrite()输出false.

java io ubuntu mkdir

0
推荐指数
1
解决办法
52
查看次数

标签 统计

java ×2

io ×1

mkdir ×1

replace ×1

string ×1

ubuntu ×1