Java String Extract extractCommands(String fileContents)

Here you can find the source of extractCommands(String fileContents)

Description

extract Commands

License

Open Source License

Declaration

public static List<String> extractCommands(String fileContents) 

Method Source Code

//package com.java2s;
/*/*from w w  w. ja v a  2s  . co  m*/
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> extractCommands(String fileContents) {
        List<String> commands = new ArrayList<String>();
        int i = 0;
        while (i < fileContents.length()) {
            int j = fileContents.indexOf(";", i);
            if (j == -1) {
                j = fileContents.length();
            }
            String command = fileContents.substring(i, j).trim();
            if (command.length() > 0) {
                commands.add(command);
            }
            i = j + 1;
        }
        return commands;
    }
}

Related

  1. extract_tokens(String in_string, String delimiters)
  2. extractAggregationPrimKeysFromSql( final String sql)
  3. extractArrayData(String input, StringBuilder output)
  4. extractArrayData(String input, StringBuilder output)
  5. extractCharNgram(String content, int n)
  6. extractData(String message)
  7. extractField(int position, String regex, String source)
  8. extractGenericTypeNames(String sig)
  9. extractHorizontalTabs(String line, int tabSize)