String replace sample example (json is there remove extension and then display)
package com.demo;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.FileUtils;
public class SampleFile {
static List<String> list = new ArrayList<String>();
static List<String> list_two = new ArrayList<String>();
static {
list.add("iPod_json");
list.add("iPod_video");
list.add("sample_iPod_json");
list.add("sample_iPod_video");
}
public static void main(String[] args) {
for (String str : list) {
if (!list_two.contains(str.replace("_json", "").replace("_video",
"")))
list_two.add(str.replace("_json","" ).replace("_video", ""));
// System.out.println(str.replace("_json","" ).replace("_video", ""));
}
for (String str : list_two) {
System.out.println(str);
}
}
}
No comments:
Post a Comment