IntelliJ IDEA多屏后窗口不顯示問題解決方案
IDEA 在接入外接屏且擴展的情況下,如果突然拔掉外接屏,就可能會產(chǎn)生IDEA 整個窗口只在屏幕的右側(cè)顯示一點點邊框且無法拖拽到當(dāng)前屏幕的情況。
在不再次接入外接屏的情況下,想要把IDEA窗口拖拽回當(dāng)前屏幕,可以找到項目中.idea 文件夾下的workspace.xml 文件
全文搜索ProjectFrameBounds 關(guān)鍵字,修改x和y的值為0或者直接將name="x",name="y"的這兩行刪除即可,然后重啟IDEA即可

因為經(jīng)常遇到這種情況,所以自己寫了個java 小工具,一鍵刪除 name="x",name="y" 這兩行記錄,同時生成一個原始文件的.bak 文件,入?yún)⒅恍枰募窂?/p>
其中的核心代碼邏輯示例如下:
(標(biāo)簽: 使用Java 實現(xiàn)刪除某個文件中 包含特定字符的行)
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;
}
//創(chuàng)建臨時備份文件
File bakFile2 = new File(bakpath2);
boolean nFlag = false;
try {
nFlag = bakFile2.createNewFile();
} catch (IOException e) {
return "創(chuàng)建臨時備份文件失敗,備份文件為:" + bakpath2 + " 錯誤信息為:" + e.getMessage();
}
if (!nFlag) {
return "創(chuàng)建臨時備份文件失敗,備份文件為:" + bakpath2;
}
String ans = getAns(path);
if (ans == null) {
return "讀取并修改原始文件失敗";
}
if (!addNewFile(bakpath2, ans)) {
return "將修改后的內(nèi)容寫入到新文件失敗";
}
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 "執(zhí)行成功";
}
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;
}
}
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
解決Springboot @Autowired 無法注入問題
WebappApplication 一定要在包的最外層,否則Spring無法對所有的類進行托管,會造成@Autowired 無法注入。接下來給大家介紹解決Springboot @Autowired 無法注入問題,感興趣的朋友一起看看吧2018-08-08
Idea 同一窗口導(dǎo)入多個項目的實現(xiàn)步驟
本文主要介紹了Idea 同一窗口導(dǎo)入多個項目的實現(xiàn)步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07
SpringBoot獲取前臺參數(shù)的六種方式以及統(tǒng)一響應(yīng)
本文主要介紹了SpringBoot獲取前臺參數(shù)的六種方式以及統(tǒng)一響應(yīng),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-03-03
Tomcat Cannot assign requested address: JVM_Bind 非端口占用沖突
這篇文章主要介紹了 Tomcat Cannot assign requested address: JVM_Bind 非端口占用沖突的相關(guān)資料,需要的朋友可以參考下2017-01-01
Java中的反射,枚舉及l(fā)ambda表達式的使用詳解
這篇文章主要為大家詳細(xì)介紹了Java的反射,枚舉及l(fā)ambda表達式,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2022-03-03

