×

intellij工程文件路径

intellij工程文件路径(idea 文件路径)

admin admin 发表于2023-03-12 06:20:08 浏览34 评论0

抢沙发发表评论

本文目录一览:

2021.3.2 idea配置文件在哪里找

在idea的快捷方式点右键,打开文件所在位置,进入idea安装位置的bin目录。

如果使用IDEA,就需要做很多配置的相关工作,让它越来越符合你的个人习惯,使用起来得心应手,这些配置信息,都保存在C盘。

找到你IDEA的安装目录,进入bin目录,去掉下面这两行路径前的注释,修改路径为你想存放的路径。

idea中获取项目中文件相对路径的方法

想要读取该项目中的resources下的prop文件夹中的text.txt文件。

// 读文件String path

this.getClass().getClassLoader().getResource("./prop/text.txt").getPath();

FileReader fr = new FileReader(path);

BufferedReader br = new BufferedReader(fr);

String str = null;while((str = br.readLine()) != null) {

System.out.println(str);

}// 关闭流br.close();

fr.close();

读文件:

public void load(String path) {

BufferedReader br = null;

try {

br = new BufferedReader(new FileReader(path));

String line = "";

while ((line = br.readLine()) != null) {

m_tbl.put(Integer.parseInt(line), true);

}

br.close();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (NumberFormatException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

扩展资料:

解决相对路径找不到的问题:

1、采用绝对路径;

2、还是使用相对路径,这时用类加载器加载文件路径。代码如下:

public void load(String path) {

BufferedReader br = null;

try {

InputStream in = SetTable.class.getClassLoader().getResourceAsStream(path);

br = new BufferedReader(new InputStreamReader(in, "UTF-8"));

String line = "";

while ((line = br.readLine()) != null) {

m_tbl.put(Integer.parseInt(line), true);

}

br.close();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (NumberFormatException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

修改IDEA缓存文件路径

第一步,找到IDEA安装位置的bin目录,再找到idea.properties文件,把 ${user.home} 替换为我们需要的路径,比如我的是 F:/PhpStorm/cache ,修改后的内容是这样的:-intellij工程文件路径

第二步,重启IDEA,会弹出一个对话框,直接点OK就行了。

至于想查看一下有没有成功,就在你换的目录下看有没有文件夹 .PhpStorm ,有就说明修改成功了。