Java Array Normalize normalizeTrimmedText(char[] ch)

Here you can find the source of normalizeTrimmedText(char[] ch)

Description

normalize Trimmed Text

License

Open Source License

Declaration

private static char[] normalizeTrimmedText(char[] ch) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static char[] normalizeTrimmedText(char[] ch) {
        char[] ch2 = new char[ch.length];
        boolean inWhitespace = false;
        int j = 0;
        for (int i = 0; i < ch.length; i++) {
            char c = ch[i];
            boolean isWhitespace = Character.isWhitespace(c);
            if (isWhitespace && !inWhitespace) {
                ch2[j] = ' ';
                j++;/*from w  ww  . j av  a2  s  .  com*/
                inWhitespace = true;
            } else if (!isWhitespace) {
                ch2[j] = c;
                j++;
                inWhitespace = false;
            }
        }
        char[] ch3 = new char[j];
        for (int i = 0; i < j; i++) {
            ch3[i] = ch2[i];
        }
        return ch3;
    }
}

Related

  1. normalizeTo(float[] in, float normsum)
  2. normalizeToInPlace(double[] in, double normsum)
  3. normalizeToLogProbs(double[] x)
  4. normalizeToOne(double[] doubles)
  5. normalizeToSumUpTo(double[] x, double sumUp)
  6. NormalizeVec2D(double[] vec)
  7. normalizeVector(double[] input)
  8. normalizeVector(Double[] vector)
  9. normalizeVector(final double[] v)