List of usage examples for org.springframework.util StringUtils delimitedListToStringArray
public static String[] delimitedListToStringArray(@Nullable String str, @Nullable String delimiter)
From source file:org.springframework.xd.extension.process.ShellCommandProcessor.java
/** * Handle extra white space between arguments *//* w ww . java 2 s. c o m*/ private List<String> parse(String command) { List<String> result = new ArrayList<String>(); for (String token : StringUtils.delimitedListToStringArray(command, " ")) { if (token.trim().length() > 0) { result.add(token); } } return result; }
From source file:test.jdbc.datasource.DataSourceInitializer.java
private void doExecuteScript(final Resource scriptResource) { if (scriptResource == null || !scriptResource.exists()) return;/*from www . ja v a 2s .co m*/ final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String[] scripts; try { String[] list = StringUtils.delimitedListToStringArray( stripComments(IOUtils.readLines(scriptResource.getInputStream())), ";"); scripts = list; } catch (IOException e) { throw new BeanInitializationException("Cannot load script from [" + scriptResource + "]", e); } for (int i = 0; i < scripts.length; i++) { final String script = scripts[i].trim(); TransactionTemplate transactionTemplate = new TransactionTemplate( new DataSourceTransactionManager(dataSource)); transactionTemplate.execute(new TransactionCallback<Void>() { @Override public Void doInTransaction(TransactionStatus status) { if (StringUtils.hasText(script)) { try { jdbcTemplate.execute(script); } catch (DataAccessException e) { if (!script.toUpperCase().startsWith("DROP")) { throw e; } } } return null; } }); } }