如何在 Mac 上找到 TextEdit?
How to find TextEdit on Mac?
我的 Java 应用程序将检测文件扩展名并使用写字板在 Windows 中打开它,如下所示:
public static Process Display_File(String File_Path)
{
String Command,Program,Suffix=File_Path.toLowerCase();
Process process=null;
if (Suffix.endsWith("txt") || Suffix.endsWith("json")) Program="C:\Program Files (x86)\Windows NT\Accessories\word_pad.exe ";
Command=Program+"\""+File_Path+"\"";
try { process=Runtime.getRuntime().exec(Command); }
catch (Exception e) { e.printStackTrace(); }
return process;
}
但是在Mac上不行,我知道在Mac上有TextEdit.app,那么如何把上面的代码改成运行呢Mac ?
改完之后是这样的:
public static Process Display_File_On_Mac(String File_Path)
{
String Command,Program,Suffix=File_Path.toLowerCase();
Process process=null;
if (Suffix.endsWith("txt") || Suffix.endsWith("json")) Program="/Applications/TextEdit.app ";
Command=Program+"\""+File_Path+"\"";
try { process=Runtime.getRuntime().exec(Command); }
catch (Exception e) { e.printStackTrace(); }
return process;
}
但是我得到了这个错误:
java.io.IOException: Cannot run program "/Applications/TextEdit.app": error=13, Permission denied
如何解决?
在 El-capitan 上,给出以下路径对我有用:
Program="open /Applications/TextEdit.app/Contents/MacOS/TextEdit";
您可以从终端 window 导航到 TextEdit.app
文件夹,并确保在尝试之前将可执行文件放在正确的位置。
此外,您需要像这样更改命令的设置:
Command = Program+ " "+File_Path;
启动 macOS Catalina 系统应用程序移动到 /System/Applicatyions 文件夹:https://support.apple.com/HT210650
因此,TextEdit 的新路径是 /System/Applications/TextEdit.app/Contents/MacOS/TextEdit
我的 Java 应用程序将检测文件扩展名并使用写字板在 Windows 中打开它,如下所示:
public static Process Display_File(String File_Path)
{
String Command,Program,Suffix=File_Path.toLowerCase();
Process process=null;
if (Suffix.endsWith("txt") || Suffix.endsWith("json")) Program="C:\Program Files (x86)\Windows NT\Accessories\word_pad.exe ";
Command=Program+"\""+File_Path+"\"";
try { process=Runtime.getRuntime().exec(Command); }
catch (Exception e) { e.printStackTrace(); }
return process;
}
但是在Mac上不行,我知道在Mac上有TextEdit.app,那么如何把上面的代码改成运行呢Mac ?
改完之后是这样的:
public static Process Display_File_On_Mac(String File_Path)
{
String Command,Program,Suffix=File_Path.toLowerCase();
Process process=null;
if (Suffix.endsWith("txt") || Suffix.endsWith("json")) Program="/Applications/TextEdit.app ";
Command=Program+"\""+File_Path+"\"";
try { process=Runtime.getRuntime().exec(Command); }
catch (Exception e) { e.printStackTrace(); }
return process;
}
但是我得到了这个错误:
java.io.IOException: Cannot run program "/Applications/TextEdit.app": error=13, Permission denied
如何解决?
在 El-capitan 上,给出以下路径对我有用:
Program="open /Applications/TextEdit.app/Contents/MacOS/TextEdit";
您可以从终端 window 导航到 TextEdit.app
文件夹,并确保在尝试之前将可执行文件放在正确的位置。
此外,您需要像这样更改命令的设置:
Command = Program+ " "+File_Path;
启动 macOS Catalina 系统应用程序移动到 /System/Applicatyions 文件夹:https://support.apple.com/HT210650
因此,TextEdit 的新路径是 /System/Applications/TextEdit.app/Contents/MacOS/TextEdit