List of usage examples for java.util List toArray
<T> T[] toArray(T[] a);
From source file:libra.Libra.java
private static String[] removeRunMode(String[] args) { List<String> param = new ArrayList<String>(); for (String arg : args) { if (!arg.equalsIgnoreCase("preprocess") && !arg.equalsIgnoreCase("core")) { param.add(arg);/*from w ww . j av a 2s . c o m*/ } } return param.toArray(new String[0]); }
From source file:Main.java
public static CharSequence[] split(CharSequence string, String pattern) { String[] parts = string.toString().split(pattern); List<CharSequence> res = new ArrayList<>(); CharSequence temp = string;//from w ww .j av a 2 s . c om int pos = 0; for (String part : parts) { res.add(string.subSequence(pos, pos + part.length())); pos += part.length(); } return res.toArray(new CharSequence[res.size()]); }
From source file:Main.java
public static void getTabList(String strTitle, final ViewPager vp, Activity activity) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); alertDialogBuilder.setTitle(strTitle); List<String> listItems = new ArrayList<String>(); for (byte i = 0; i < vp.getAdapter().getCount(); i++) { listItems.add(vp.getAdapter().getPageTitle(i).toString()); }//from w w w. j a va 2s . com alertDialogBuilder.setItems(listItems.toArray(new CharSequence[listItems.size()]), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { vp.setCurrentItem(which); } }).show(); }
From source file:testReflection.java
public static Field[] getAllFields(Class klass) { List<Field> fields = new ArrayList<Field>(); fields.addAll(Arrays.asList(klass.getDeclaredFields())); if (klass.getSuperclass() != null) { fields.addAll(Arrays.asList(getAllFields(klass.getSuperclass()))); }//from w w w .j av a 2s . c om return fields.toArray(new Field[] {}); }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
public static String[] getModels(String[] modelNames) { File dir = new File(Config.getConfiguration().getString(MODELPATH)); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }
From source file:edu.harvard.iq.dvn.ingest.dsb.impl.DvnDSButil.java
/** * List version/*w w w. j a v a 2s .c om*/ * * @param * @return */ public static String joinNelementsPerLine(List<String> vnl, int divisor, String sp, boolean quote, String qm, String lnsp) { String[] vn = (String[]) vnl.toArray(new String[vnl.size()]); return joinNelementsPerLine(vn, divisor, sp, quote, qm, lnsp); }
From source file:io.github.pellse.decorator.util.reflection.ReflectionUtils.java
@SuppressWarnings("unchecked") public static <T> T[] insert(T[] objArray, int index, T obj) { if (index > -1) { List<T> list = new ArrayList<>(Arrays.asList(objArray)); list.add(index, obj);//from w w w .j av a 2 s . co m return list.toArray((T[]) Array.newInstance(objArray.getClass().getComponentType(), 0)); } return objArray; }
From source file:Main.java
/** * Returns an array of all the Element children of a DOM node. * * @param parent parent node//from w ww . java 2 s . c o m * @return children array */ public static Element[] getChildren(Node parent) { NodeList nodeList = parent.getChildNodes(); int nnode = nodeList.getLength(); List elList = new ArrayList(nnode); for (int i = 0; i < nnode; i++) { Node node = nodeList.item(i); if (node instanceof Element) { elList.add((Element) node); } } return (Element[]) elList.toArray(new Element[0]); }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
/** * Gets the models.// w w w . j ava 2s .c om * * @return the models */ public static String[] getModels() { File dir = new File(Config.getConfiguration().getString(MODELPATH)); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> models = new ArrayList<>(); String[] modelNames = getModelNames(); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
/** * Gets the models. This method is used if ModelPath is passed as parameter. * /*from w w w. j a va2s . co m*/ * * @return the models */ public static String[] getModels(String modelDirectory) { File dir = new File(modelDirectory); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> models = new ArrayList<>(); String[] modelNames = getModelNames(); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }