快生活 - 生活常识大全

读取文件方法


  private void isAsyuku() throws Exception {
  InputStream file = upFile.getInputstream();
  int index = StringUtils.split(upFile.getFileName(), "").length - 1;
  String fileName1 = StringUtils.split(upFile.getFileName(), "")[index];
  if(StringUtils.split(fileName1, ".").length == 1){
  return;
  }
  String extension = StringUtils.split(fileName1, ".")[1];
  StringUtils.equals(extension, "");
  if (StringUtils.equals(extension, "gif") || StringUtils.equals(extension, "bmp")
  || StringUtils.equals(extension, "jpg") || StringUtils.equals(extension, "tif")
  || StringUtils.equals(extension, "tiff") || StringUtils.equals(extension, "GIF")
  || StringUtils.equals(extension, "BMP") || StringUtils.equals(extension, "JPG")
  || StringUtils.equals(extension, "TIF") || StringUtils.equals(extension, "TIFF")) {
  if (StringUtils.equals(extension, "TIFF") || StringUtils.equals(extension, "TIF")
  || StringUtils.equals(extension, "tif") || StringUtils.equals(extension, "tiff")) {
  IIORegistry registry = IIORegistry.getDefaultInstance();
  registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriterSpi());
  registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi());
  }
  // ファイルのピクセールサイズを取得する
  BufferedImage image = ImageIO.read(file);
  BigDecimal width = BigDecimal.valueOf(image.getWidth());
  BigDecimal height = BigDecimal.valueOf(image.getHeight());
  if (width.compareTo(new BigDecimal(5000)) > 0 || height.compareTo(new BigDecimal(5000)) > 0) {
  this.imageFlage = "true";
  } else {
  this.imageFlage = "false";
  }
  }
  }
网站目录投稿:巧风