java processbuilder中字符串参数的最大长度 [英] Maximum length of string argument in java processbuilder
问题描述
我知道当我们从取决于操作系统的命令行/终端执行应用程序时存在字符串限制.
但是如果我们使用 Java ProcessBuilder 来执行应用程序,在 java ProcessBuilder 中是否有任何最大字符串长度作为参数传递?
I know there is a string limitation when we execute application from command line / terminal which depends on the OS.
But if we use the Java ProcessBuilder to execute application, is there any maximum string length to be passed as argument in the java ProcessBuilder ?
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
谢谢
推荐答案
如果您查看 ProcessBuilder 源代码,流程创建将委托给特定于操作系统的 java.lang.ProcessImpl
.
If you look at ProcessBuilder source code the process creation is delegated to a OS specific java.lang.ProcessImpl
.
例如,ProcessImpl
的 Windows 版本调用 CreateProcess 在 Win API 中,传递命令行字符串.参数 lpCommandLine
的文档说明:此字符串的最大长度为 32,768 个字符".
For instance the Windows version of ProcessImpl
calls CreateProcess in the Win API, passing the commandline string. The documentation for parameter lpCommandLine
states: "The maximum length of this string is 32,768 characters".
所以是的,根据创建进程的操作系统功能,会有操作系统特定的长度限制.
So yes there will be OS specific length limitations, based on the OS function to create the process.
这篇关于java processbuilder中字符串参数的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!