Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. package Obsluga;
  2.  
  3. import java.io.UnsupportedEncodingException;
  4. import java.net.URLDecoder;
  5. import java.net.URLEncoder;
  6.  
  7. /**
  8. * @author DyrczJelenDragRopek
  9. * Klasa zawiera metody sluzace kodowaniu i odkowaniu wyslanej wiadomosci w sieci
  10. * Wykorzystuje URLEncoder - UTF-8
  11. * */
  12.  
  13. public class Encoding {
  14.  
  15. /**
  16. * Zakodowanie wiadomosci
  17. * */
  18.  
  19. public static String encode(String text){
  20. String result = "";
  21. if(text == null){
  22. return result;
  23. }
  24. try{
  25. result = URLEncoder.encode(text,"UTF-8");
  26. }catch (UnsupportedEncodingException ex){
  27. ex.printStackTrace();
  28. }
  29. return result;
  30. }
  31.  
  32. /**
  33. * Odkodowanie wiadomosci
  34. * */
  35. public static String decode(String text){
  36. String result = "";
  37. if(text == null){
  38. return result;
  39. }
  40. try{
  41. result = URLDecoder.decode(text,"UTF-8");
  42. }catch (UnsupportedEncodingException ex){
  43. ex.printStackTrace();
  44. }
  45. return result;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement