Here you can find the source of sortSubFiles(String[] p_subFiles)
Parameter | Description |
---|---|
p_subFiles | Separated files without order |
private static String[] sortSubFiles(String[] p_subFiles)
//package com.java2s; /**//from ww w . ja v a2s. com * Copyright 2009 Welocalize, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. * * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * */ public class Main { /** * Sort the separated file by the suffix number in the filename * * @param p_subFiles * Separated files without order * @return String[] Sorted separated file array * * @version 1.0 * @since 8.2.2 */ private static String[] sortSubFiles(String[] p_subFiles) { if (p_subFiles == null || p_subFiles.length == 0) return p_subFiles; int length = p_subFiles.length; String[] sortedSubFiles = new String[length]; String tmp = ""; int index = -1; for (int i = 0; i < length; i++) { tmp = p_subFiles[i]; tmp = tmp.substring(0, tmp.lastIndexOf(".")); tmp = tmp.substring(tmp.lastIndexOf("_") + 1); index = Integer.parseInt(tmp) - 1; sortedSubFiles[index] = p_subFiles[i]; } return sortedSubFiles; } }