Browse Source

优化读写逻辑

bugfix
zhuangjiaju 5 years ago
parent
commit
31c362cd87
  1. 4
      src/main/java/com/alibaba/excel/converters/inputstream/InputStreamImageConverter.java
  2. 2
      src/main/java/com/alibaba/excel/util/FileUtils.java
  3. 2
      src/main/java/com/alibaba/excel/util/IoUtils.java

4
src/main/java/com/alibaba/excel/converters/inputstream/InputStreamImageConverter.java

@ -8,7 +8,7 @@ import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.IOUtils;
import com.alibaba.excel.util.IoUtils;
/**
* File and image converter
@ -35,7 +35,7 @@ public class InputStreamImageConverter implements Converter<InputStream> {
@Override
public CellData convertToExcelData(InputStream value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws IOException {
return new CellData(IOUtils.toByteArray(value));
return new CellData(IoUtils.toByteArray(value));
}
}

2
src/main/java/com/alibaba/excel/util/FileUtils.java

@ -36,7 +36,7 @@ public class FileUtils {
InputStream in = openInputStream(file);
try {
final long fileLength = file.length();
return fileLength > 0 ? IOUtils.toByteArray(in, (int)fileLength) : IOUtils.toByteArray(in);
return fileLength > 0 ? IoUtils.toByteArray(in, (int)fileLength) : IoUtils.toByteArray(in);
} finally {
in.close();
}

2
src/main/java/com/alibaba/excel/util/IOUtils.java → src/main/java/com/alibaba/excel/util/IoUtils.java

@ -10,7 +10,7 @@ import java.io.OutputStream;
*
* @author Jiaju Zhuang
*/
public class IOUtils {
public class IoUtils {
public static final int EOF = -1;
/**
* The default buffer size ({@value}) to use for
Loading…
Cancel
Save