Example usage for org.apache.commons.lang ArrayUtils remove

List of usage examples for org.apache.commons.lang ArrayUtils remove

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils remove.

Prototype

private static Object remove(Object array, int index) 

Source Link

Document

Removes the element at the specified position from the specified array.

Usage

From source file:topics.TopicDocRewriter.java

private void filterFile(BufferedReader input, BufferedWriter output, TopicDocTermFilter filter)
        throws IOException {
    String inputline;//from  w  w w  .jav  a  2s .  co m
    while ((inputline = input.readLine()) != null) {
        String[] inputline_array = inputline.split(" ");

        // Passing document terms through the TopicDocTermFilter to determine whether they will
        // be copied to the output file or not
        for (int i = 2; i < inputline_array.length; i++) {
            if (Synset.matchesPattern(inputline_array[i])) {
                if (!filter.acceptSynset(new Synset(inputline_array[i]))) {
                    inputline_array = (String[]) ArrayUtils.remove(inputline_array, i);
                }
            }
            // Term is a word
            else {
                if (!filter.acceptWord(inputline_array[i])) {
                    inputline_array = (String[]) ArrayUtils.remove(inputline_array, i);
                }
            }
        }

        if (inputline_array.length > 2) {
            // Writing document id and length to the output file
            output.write(inputline_array[0] + " " + (inputline_array.length - 2));

            // Writing terms to file
            for (int i = 2; i < inputline_array.length; i++) {
                output.write(" " + inputline_array[i]);
            }

            // Completing the document with a newline
            output.newLine();
        }
    }
}

From source file:ua.aits.Carpath.controller.AjaxController.java

@RequestMapping(value = { "/system/downloadimage/", "/system/downloadimage", "/Carpath/system/downloadimage/",
        "/Carpath/system/downloadimage" }, method = RequestMethod.POST)
public @ResponseBody String downloadimage(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    request.setCharacterEncoding("UTF-8");
    String imageString = request.getParameter("url").substring(request.getParameter("url").indexOf(",") + 1);
    BufferedImage image = null;/*from  ww  w .  jav  a2 s. c om*/
    byte[] imageByte;

    BASE64Decoder decoder = new BASE64Decoder();
    imageByte = decoder.decodeBuffer(imageString);
    ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
    image = ImageIO.read(bis);
    bis.close();

    String ur = request.getParameter("url");
    String[] path = request.getParameter("path").split(",");
    String filename = path[path.length - 1].split("\\.")[0];
    String[] newPath = (String[]) ArrayUtils.remove(path, path.length - 1);
    String pathW = "";
    for (String temp : newPath) {
        pathW += temp + "/";
    }
    File outputfile = new File(Constants.HOME + pathW + "cropped-" + filename + ".png");
    ImageIO.write(image, "png", outputfile);
    return pathW + "cropped-" + filename + ".png";
}

From source file:uk.ac.diamond.scisoft.analysis.peakfinding.SequenceEntropy.java

@Override
protected double calculateSignificance(int position, int windowSize, IDataset yData) {

    IDataset localSeq = yData.getSlice(new int[position - windowSize], new int[position + windowSize],
            new int[1]);
    DoubleDataset localDoubleSeq = (DoubleDataset) DatasetUtils.cast(localSeq, Dataset.FLOAT64);

    int bandwidth = 5;
    double[] fullSequence = localDoubleSeq.getData();
    double[] subSequence = ArrayUtils.remove(fullSequence, windowSize);

    double windowEntropy = calculateEntropy(fullSequence, bandwidth);
    double entropyLessPoint = calculateEntropy(subSequence, bandwidth);

    double sig = windowEntropy - entropyLessPoint;

    return sig;//from   www  .  j  ava  2  s. c  o m
}