Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public class Base64{
  2.  
  3. public static int getBase64ByteSize(String str){
  4. String[] specialSigns = new String[] {"\u00C4","\u00E4","\u00D6"};
  5.  
  6. int amountspecialSigns = countSpecialSigns(str, specialSigns);
  7.  
  8. int n = str.length();
  9.  
  10. int z = 4 * (int) Math.ceil( (double) n/3);
  11.  
  12. return z;
  13. }
  14.  
  15. public static int countSpecialSigns(String str, String[] specialSigns){
  16. int count = 0;
  17. for (int i=0; i < str.length(); i++){
  18. for (int l=0; l< specialSigns.length; l++){
  19. if (str.charAt(i).toString() == specialSigns[l]){
  20. count++;
  21. }
  22. }
  23. }
  24. return count;
  25. }
  26.  
  27.  
  28.  
  29.  
  30. public static void main(String[] args){
  31.  
  32. System.out.println(getBase64ByteSize("Hällo"));
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement