In this source code, I'm trying to open hosts file with notepad.
(在此源代码中,我试图使用记事本打开hosts文件。)
Is there any way that i can try?? (有什么办法可以尝试吗?)
**hosts file is not in txt format. (**主机文件不是txt格式。)
this program is to add "youtube.com 127.0.0.1" in hosts file so that i can ban youtube in my computer (该程序是在主机文件中添加“ youtube.com 127.0.0.1”,以便我可以在计算机中禁止YouTube)
//youtube ban
import java.awt.Desktop;
import java.io.*;
public class main
{
public static void main(String[] args)
{
try
{
File file = new File("C:\windows\System32\drivers\etc\hosts");
File file2 = new File("C:\Users\junes\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Notepad");
if(!Desktop.isDesktopSupported())
{
System.out.println("not supported");
return;
}
Desktop desktop = Desktop.getDesktop();
if(file.exists())
desktop.open(file );
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
(})
ask by BurdinCake translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…