fork download
  1. import com.google.common.base.Charsets;
  2. import com.google.common.hash.Hashing;
  3. import java.text.MessageFormat;
  4. import com.google.common.collect.FluentIterable;
  5.  
  6. import java.util.Arrays;
  7. import java.util.List;
  8. import java.util.Iterator;
  9. /**
  10.  * Use this class to change the password stored in the databae from one that is
  11.  * visible as plain text (a security threat) to one that is "hashed". Hashing is
  12.  * a one-way encryption system. Hashes can be generated but cannot be reverse
  13.  * engineered, which is why they are called one-way hashes. Use this class to
  14.  * generate a hashed password, based on the original plain text version, using
  15.  * SHA-256, which is a superior hashing algorithm. Then copy the output from the
  16.  * console and use it to replace what you have in your database.
  17.  *
  18.  * @author jlombardo
  19.  */
  20. public class Main {
  21.  
  22. public static void main(String[] args) {
  23. List<String> strings = Arrays.asList("hello", "world", "apple", "banana", "cat");
  24.  
  25. Iterator testIterator = FluentIterable.from(strings)
  26. .transformAndConcat(word -> {
  27. if (word.contains("a")) {
  28. return Arrays.asList(word);
  29. } else {
  30. return Arrays.asList();
  31. }
  32. }).iterator();
  33.  
  34. while( testIterator.hasNext()) {
  35. System.out.println("List length " + testIterator.next());
  36. }
  37. }
  38. }
Success #stdin #stdout 0.13s 60108KB
stdin
Standard input is empty
stdout
List length apple
List length banana
List length cat