Advertisement
Guest User

Untitled

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