Package com.jdroid.java.exception

Examples of com.jdroid.java.exception.UnexpectedException


   */
  public static String toString(File file) {
    try {
      return FileUtils.toString(new FileInputStream(file));
    } catch (FileNotFoundException e) {
      throw new UnexpectedException(
          new StringBuilder("The file doesn't exist [").append(file).append("]").toString(), e);
    }
  }
View Full Code Here


        }
        firstLine = false;
        contentBuilder.append(text);
      }
    } catch (IOException e) {
      throw new UnexpectedException("Error reading the stream", e);
    } finally {
      if (closeStream) {
        safeClose(in);
      }
    }
View Full Code Here

        dir.mkdirs();
      }
      out = new FileOutputStream(destin);
      FileUtils.copyStream(source, out);
    } catch (IOException e) {
      throw new UnexpectedException(
          new StringBuilder("Error copying the file to [").append(destin).append("]").toString(), e);
    } finally {
      safeClose(out);
    }
  }
View Full Code Here

      byte[] buffer = new byte[FileUtils.BUFFER_SIZE];
      while ((count = source.read(buffer, 0, FileUtils.BUFFER_SIZE)) != -1) {
        destin.write(buffer, 0, count);
      }
    } catch (IOException e) {
      throw new UnexpectedException("Error copying file", e);
    } finally {
      if (closeOutputStream) {
        safeClose(destin);
      }
    }
View Full Code Here

      // Get a list of the files to zip
      File directoryToZip = new File(directoryToZipPath);
      zipFileItem(directoryToZipPath, zipOutputStream, directoryToZip, null);
      return zipFile;
    } catch (FileNotFoundException e) {
      throw new UnexpectedException(e);
    } finally {
      try {
        zipOutputStream.close();
      } catch (IOException e) {
        LOGGER.warn("Exception thrown when the zipOutputStream was being closed", e);
View Full Code Here

          FileUtils.copyStream(entryInputStream, zipOutputStream, false);
          entryInputStream.close();
        }
      }
    } catch (FileNotFoundException e) {
      throw new UnexpectedException(e);
    } catch (IOException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

  public void setEntity(String content) {
    try {
      entity = new StringEntity(content, HTTP.UTF_8);
      ApacheHttpWebService.LOGGER.debug("Entity: " + content);
    } catch (UnsupportedEncodingException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

      for (Entry<String, String> entry : getQueryParameters().entrySet()) {
        nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
      }
      httpEntityEnclosingRequestBase.setEntity(new UrlEncodedFormEntity(nameValuePairs, EncodingUtils.UTF8));
    } catch (UnsupportedEncodingException e) {
      throw new UnexpectedException(e);
    }
  }
View Full Code Here

  public void addPart(String name, Object value, String mimeType) {
    if (value != null) {
      try {
        multipartEntity.addPart(name, new StringBody(value.toString(), mimeType, Charset.defaultCharset()));
      } catch (UnsupportedEncodingException e) {
        throw new UnexpectedException(e);
      }
    }
  }
View Full Code Here

  public void addPart(String name, Object value, String mimeType) {
    if (value != null) {
      try {
        multipartEntity.addPart(name, new StringBody(value.toString(), mimeType, Charset.defaultCharset()));
      } catch (UnsupportedEncodingException e) {
        throw new UnexpectedException(e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.jdroid.java.exception.UnexpectedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.