Example usage for java.io UnsupportedEncodingException printStackTrace

List of usage examples for java.io UnsupportedEncodingException printStackTrace

Introduction

In this page you can find the example usage for java.io UnsupportedEncodingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.app.framework.listeners.ApplicationListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    System.out.println("Hello. Application Started.");
    System.out.println("Working Dir: " + Application.getWorkingDir().getAbsolutePath());

    String s = new String("mcg");
    System.out.println("" + s);
    String md5 = MD5Utils.md5(s);

    System.out.println(md5);/*  ww w .j a  v a 2 s  .  c  o m*/

    SecretKey key = AESUtils.generateSecretKey();
    byte[] keyBytes = AESUtils.getKeyBytes(key);
    key = AESUtils.getSecretKey(keyBytes);
    String encrypted = null;
    try {
        encrypted = Base64.encodeBase64String(AESUtils.encrypt(md5, key));
        byte[] decrypted = AESUtils.decrypt(Base64.decodeBase64(encrypted.getBytes("utf-8")), key);
        System.out.println(encrypted);
        System.out.println(new String(decrypted));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

}

From source file:com.github.liyp.rabbitmq.demo.FastJsonMessageConverter.java

@SuppressWarnings("unchecked")
public <T> T fromMessage(Message message, T t) {
    String json = "";
    try {//ww w. j ava  2  s .  c o m
        json = new String(message.getBody(), defaultCharset);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return (T) JSON.parseArray(json, t.getClass());
}

From source file:org.changhong.sync.web.AnonymousConnection.java

@Override
public String put(String uri, String data) throws UnknownHostException {

    // Prepare a request object
    HttpPut httpPut = new HttpPut(uri);

    try {// w  w w. j  ava2 s . co m
        // The default http content charset is ISO-8859-1, JSON requires UTF-8
        httpPut.setEntity(new StringEntity(data, "UTF-8"));
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
        return null;
    }

    httpPut.setHeader("Content-Type", "application/json");
    httpPut.addHeader("X-Tomboy-Client", Tomdroid.HTTP_HEADER);
    HttpResponse response = execute(httpPut);
    return parseResponse(response);
}

From source file:com.baoyz.bigbang.segment.NetworkParser.java

@Nullable
private Request createRequest(String text) {
    Request request = null;//from   w ww  . j av a 2  s.c  o  m
    try {
        request = new Request.Builder().get()
                .url("http://fenci.kitdroid.org:3000/?text=" + URLEncoder.encode(text, "utf-8")).build();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return request;
}

From source file:cn.edu.xmu.comm.action.json.TempParkingBillAddAction.java

public String execute() {
    try {/*w ww  .ja v  a 2s  . c o  m*/
        license = URLDecoder.decode(license, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    data = new HashMap<String, Object>();
    Boolean hasFreeParkPlace = parkingService.hasFreeTempParkPlace();
    Boolean hasOwner = propertyService.hasOwner(ownerId);
    data.put("hasFreeParkPlace", hasFreeParkPlace ? "true" : "false");
    data.put("hasOwner", hasOwner ? "true" : "false");
    if (hasFreeParkPlace && hasOwner) {
        Integer parkBillId = parkingService.addParkBill(ownerId, license).getId();
        data.put("parkBillId", parkBillId.toString());
    }
    return SUCCESS;
}

From source file:org.jfree.eastwood.ChartApplet.java

/**
 * Starts the applet.//from w  w  w .  j  a va  2s  .co m
 */
public void start() {
    String chartSpec = getParameter("chart");
    try {
        Map params = Parameters.parseQueryString(chartSpec);
        JFreeChart chart = ChartEngine.buildChart(params, new Font("Dialog", Font.PLAIN, 12));
        this.chartPanel.setChart(chart);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
}

From source file:ch.astina.hesperid.web.pages.admin.agentbundle.AgentBundleIndex.java

private String encodeStr(String str) {
    try {/*  w ww .j  a  v  a 2 s  .c  o  m*/
        return URLEncoder.encode(str, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.dss886.nForumSDK.http.PostMethod.java

public PostMethod(DefaultHttpClient httpClient, String auth, String url, ParamOption params) {
    this.httpClient = httpClient;
    httpPost = new HttpPost(url);
    try {/*  w ww. j av  a  2 s  .  c o  m*/
        httpPost.setEntity(new UrlEncodedFormEntity(params.toNamePair(), "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    httpPost.setHeader("Accept-Encoding", "gzip, deflate");
    httpPost.setHeader("Authorization", "Basic " + auth);
}

From source file:com.cloudera.recordbreaker.hive.RecordBreakerSerDe.java

/**
 * <code>initDeserializer</code> sets up the RecordBreaker-specific
 * (that is, specific to UnknownText) parts of the SerDe.  In particular,
 * it loads in the text scanner description.
 *///from  ww  w. ja va  2 s  .  c  o m
void initDeserializer(String recordBreakerTypeTreePayload) {
    try {
        DataInputStream in = new DataInputStream(new FileInputStream(new File(recordBreakerTypeTreePayload)));
        this.typeTree = InferredType.readType(in);
    } catch (UnsupportedEncodingException uee) {
        uee.printStackTrace();
    } catch (IOException iex) {
        iex.printStackTrace();
    }
}

From source file:ca.ualberta.cs.swapmyride.Misc.SavePhotoRunnable.java

public void run() {
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpAdd = new HttpPost(url);
    HttpResponse response;//from ww  w . j  a v a2s.c o m
    StringEntity stringEntity = null;

    try {
        stringEntity = new StringEntity(gson.toJson(photo));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    httpAdd.setEntity(stringEntity);
    httpAdd.setHeader("Accept", "application/json");

    //possible IO Error and an HTTP apache error
    try {
        response = httpClient.execute(httpAdd);
        String status = response.getStatusLine().toString();
        Log.i("NetworkDataManager", status);
    } catch (Exception e) {
        e.printStackTrace();
    }
}