Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Obsluga;
- import java.io.UnsupportedEncodingException;
- import java.net.URLDecoder;
- import java.net.URLEncoder;
- /**
- * @author DyrczJelenDragRopek
- * Klasa zawiera metody sluzace kodowaniu i odkowaniu wyslanej wiadomosci w sieci
- * Wykorzystuje URLEncoder - UTF-8
- * */
- public class Encoding {
- /**
- * Zakodowanie wiadomosci
- * */
- public static String encode(String text){
- String result = "";
- if(text == null){
- return result;
- }
- try{
- result = URLEncoder.encode(text,"UTF-8");
- }catch (UnsupportedEncodingException ex){
- ex.printStackTrace();
- }
- return result;
- }
- /**
- * Odkodowanie wiadomosci
- * */
- public static String decode(String text){
- String result = "";
- if(text == null){
- return result;
- }
- try{
- result = URLDecoder.decode(text,"UTF-8");
- }catch (UnsupportedEncodingException ex){
- ex.printStackTrace();
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement