Tag: space

带有多个带空格的参数的Java ProcessBuilder

我知道有很多关于从java执行进程的问题。但我无法使用提供的答案来解决我的问题。 我正在尝试从java应用程序创建postgresql数据库备份。 我使用以下代码 //ProcessBuilder probuilder = new ProcessBuilder(new String[]{“cmd”,”/c”,”D:/PostgreSQL 8.2/bin/pg_dump.exe”,”-U”,”usr”,”-i”,”-h”,”localhost”,”-p”,”5432″,”-F”,”c”,”-b”,”-f”,”D:/backup test/backups/test_27-1-2013_210.backup”, “test”}); //ProcessBuilder probuilder = new ProcessBuilder(new String[]{“cmd”,”/c”,”D:\\PostgreSQL 8.2\\bin\\pg_dump.exe”,”-U”,”usr”,”-i”,”-h”,”localhost”,”-p”,”5432″,”-F”,”c”,”-b”,”-f”,”D:\\backup test\\backups\\test_27-1-2013_210.backup”, “test”}); ProcessBuilder probuilder = new ProcessBuilder(new String[]{“cmd”,”/c”,”\”D:\\PostgreSQL 8.2\\bin\\pg_dump.exe\””,”-U”,”usr”,”-i”,”-h”,”localhost”,”-p”,”5432″,”-F”,”c”,”-b”,”-f”,”\”D:\\backup test\\backups\\test_27-1-2013_210.backup\””, “test”}); Map env = probuilder.environment(); env.put(“PGPASSWORD”, “mypass”); final Process process = probuilder.start(); 执行上面的代码后,我得到以下错误: D:\PostgreSQL’ is not recognized as an internal or external command, operable program or […]