Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
951 B
4
Indexable
Never
public void populateFileCode(String url, File file, JPanel panel) {
    HttpPost httpPost = new HttpPost(url);
    System.out.println(file + " uploading ...");
    FileBody uploadFilePart = new FileBody(file);
    MultipartEntityBuilder builder = MultipartEntityBuilder.create()
      .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
      .setCharset(Charset.forName("UTF-8"))
      .addPart("file", (ContentBody)uploadFilePart);
    httpPost.setEntity(builder.build());
    try {
      Exception exception1 = null, exception2 = null;
      try {
      
      } finally {
        exception2 = null;
        if (exception1 == null) {
          exception1 = exception2;
        } else if (exception1 != exception2) {
          exception1.addSuppressed(exception2);
        } 
      } 
    } catch (IOException exp) {
      exp.printStackTrace();
      JOptionPane.showMessageDialog(panel, "File server is not working.", 
          "Error", 0);
    } 
  }