java processbuilder中字符串参数的最大长度 [英] Maximum length of string argument in java processbuilder

查看:96
本文介绍了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 lpCommandLinestates: "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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆