Java 如何在intellij中更改文件的只读状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44265670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Change Read-Only Status of Files in intellij
提问by Harry Prn Dz
回答by Carlos Bernardes
To toggle read-only attribute of a file
切换文件的只读属性
Open file in the editor, or select it in the Project tool window. Do one of the following:
在编辑器中打开文件,或在项目工具窗口中选择它。执行以下操作之一:
On the main menu, choose File | Make File Read-Only, or File | Make File Writable.
在主菜单上,选择文件 | 使文件只读,或文件 | 使文件可写。
Click the lock icon in the Status bar.
单击状态栏中的锁定图标。
回答by H?vard Geithus
If IntelliJ IDEA is unable to change the file permissions using File | Make File Writable, then perhaps another user is owning that file, e.g. root (use this command to verify: ls -hal /path/to/File.java
)
如果 IntelliJ IDEA 无法使用File |更改文件权限 make文件可写的话,或许另一个用户拥有该文件,如根(使用此命令来验证:ls -hal /path/to/File.java
)
If someone else owns it, for whatever reason, you can change the permissions yourself using the chowncommand in the terminal:
如果其他人拥有它,无论出于何种原因,您都可以在终端中使用chown命令自己更改权限:
sudo chown yourusername /path/to/File.java
,
sudo chown yourusername /path/to/File.java
,
where yourusername
is the same user that you used to launch Intellij IDEA.
yourusername
您用于启动 Intellij IDEA 的同一用户在哪里。
回答by Long Nguyen
If you're using Mac. Follow bellow steps:
如果您使用的是 Mac。请按照以下步骤操作:
- Open that file by Finder
- Right click and select
Get Info
- In that File Info window, select
Sharing and Permissions
, changePrivilege
as you expected. Before changing, you would remember unlocking your change permission by click on aLocker Icon
at bottom right.
- 用 Finder 打开那个文件
- 右键单击并选择
Get Info
- 在该文件信息窗口中,选择
Sharing and Permissions
,Privilege
按预期进行更改。在更改之前,您会记得通过单击右下角的 a 来解锁您的更改权限Locker Icon
。
回答by Carlos Murray
On your top-left corner in the drop-down where you have Tests,Production,Problems switch/choose from Project or any other directory you've choosen to Packages, you'll have your packages editable, files in the Project folder are not editable although they end with .class
extension.
在下拉菜单的左上角,您可以从 Project 或您选择的任何其他目录中切换/选择 Tests、Production、Problems 到 Packages,您将可以编辑您的包,Project 文件夹中的文件不是可编辑,尽管它们以.class
扩展名结尾。
回答by tryingsohard
I was just having this issue and I finally figured out where I was going wrong.
我刚刚遇到这个问题,我终于弄清楚我哪里出错了。
Over an hour of suggestions from Google didn't help. It turns out I was on files selected in the -out > production > MyPath folder instead of the -src folder in my project sidebar. Selecting the -scr > MyClass file allows me to do what I want to do.
来自谷歌的一个多小时的建议没有帮助。事实证明,我是在 -out > production > MyPath 文件夹中选择的文件,而不是项目侧栏中的 -src 文件夹。选择 -scr > MyClass 文件允许我做我想做的事情。
回答by Dato Gogshelidze
For Mac, it definitely works:
对于 Mac,它绝对有效:
sudo chmod -R 777 /YourDirectory
sudo chmod -R 777 /YourDirectory
回答by Manish Chauhan
This error appears when the other user has created those files.
1. Right click on the file or folder to be deleted.
2. Choose reveal in folder option.
3. Delete the file and enter the password.
4. Files will be deleted.
当其他用户创建这些文件时会出现此错误。
1. 右键单击要删除的文件或文件夹。
2. 选择在文件夹选项中显示。
3. 删除文件并输入密码。
4. 文件将被删除。