IDEA 在接入外接屏且扩展的情况下,如果突然拔掉外接屏,就可能会产生IDEA 整个窗口只在屏幕的右侧显示一点点边框且无法拖拽到当前屏幕的情况。
在不再次接入外接屏的情况下,想要把IDEA窗口拖拽回当前屏幕,可以找到项目中.idea 文件夹下的workspace.xml 文件
全文搜索ProjectFrameBounds 关键字,修改x和y的值为0或者直接将name="x",name="y"的这两行删除即可,然后重启IDEA即可
因为经常遇到这种情况,所以自己写了个java 小工具,一键删除 name="x",name="y" 这两行记录,同时生成一个原始文件的.bak 文件,入参只需要文件路径
其中的核心代码逻辑示例如下:
(标签: 使用Java 实现删除某个文件中 包含特定字符的行)
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
import java.io.*;
/**
* @author jiashubing
* @since 2019/5/22
*/
public class DeleteLine {
public static void main(String[] args) {
String path = "C:\\\\Users\\\\jiashubing\\\\Desktop\\\\ttt\\\\workspace.xml" ;
deleteLine(path);
}
private static String deleteLine(String path) {
int a = path.lastIndexOf( '/' );
int b = path.lastIndexOf( '\\\\' );
if (a < 0 && b < 0 ) {
return "没有目录分隔符" ;
}
//删除原来的备份文件
String bakpath = path + ".bak" ;
if (deleteFile(bakpath)) {
return "删除原始的备份文件失败,备份文件为:" + bakpath;
}
String bakpath2 = path + ".bak2" ;
if (deleteFile(bakpath2)) {
return "删除原始的临时备份文件失败,备份文件为:" + bakpath2;
}
//创建临时备份文件
File bakFile2 = new File(bakpath2);
boolean nFlag = false ;
try {
nFlag = bakFile2.createNewFile();
} catch (IOException e) {
return "创建临时备份文件失败,备份文件为:" + bakpath2 + " 错误信息为:" + e.getMessage();
}
if (!nFlag) {
return "创建临时备份文件失败,备份文件为:" + bakpath2;
}
String ans = getAns(path);
if (ans == null ) {
return "读取并修改原始文件失败" ;
}
if (!addNewFile(bakpath2, ans)) {
return "将修改后的内容写入到新文件失败" ;
}
File oldFile = new File(path);
boolean mvFlag = oldFile.renameTo( new File(bakpath));
if (!mvFlag) {
return "将原始文件重命名成备份文件失败" ;
}
boolean mvFlag2 = bakFile2.renameTo( new File(path));
if (!mvFlag2) {
return "将临时备份文件重命名成原始文件失败" ;
}
return "执行成功" ;
}
private static boolean deleteFile(String bakpath) {
File bakFile = new File(bakpath);
if (bakFile.exists() && bakFile.isFile()) {
boolean delFlag = bakFile.delete();
if (!delFlag) {
return true ;
}
}
return false ;
}
private static String getAns(String path) {
File oldFile = new File(path);
if (!oldFile.exists() || !oldFile.isFile()) {
return null ;
}
StringBuilder ans = new StringBuilder();
String encoding = "UTF-8" ;
try (InputStreamReader read = new InputStreamReader(
new FileInputStream(oldFile), encoding);
BufferedReader bufferedReader = new BufferedReader(read)) {
String lineTxt = null ;
while ((lineTxt = bufferedReader.readLine()) != null ) {
if (lineTxt.contains( "name=\\"x\\"" ) || lineTxt.contains( "name=\\"y\\"" )) {
continue ;
}
ans.append(lineTxt + "\\n" );
}
} catch (Exception e) {
return null ;
}
return ans.toString();
}
private static boolean addNewFile(String path, String ans) {
File file = new File(path);
try (Writer out = new FileWriter(file)) {
out.write(ans);
} catch (IOException e) {
return false ;
}
return true ;
}
}
|
相关文章
猜你喜欢
- ASP.NET自助建站系统中如何实现多语言支持? 2025-06-10
- 64M VPS建站:如何选择最适合的网站建设平台? 2025-06-10
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
Linux下进程管理工具Supervisor的安装配置和基本使用
2025-05-27 54 -
2025-06-04 55
-
2025-05-25 22
-
2025-05-25 35
-
2025-05-29 98
热门评论