com.talk2object.plum.input.value.MemoryFile Maven / Gradle / Ivy
The newest version!
package com.talk2object.plum.input.value;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.tika.Tika;
/**
* byte array
*
* @author jackding
*
*/
public class MemoryFile extends AbstractFile {
private byte[] data;
public MemoryFile(byte[] data) {
this.data = data;
ByteArrayInputStream bais = new ByteArrayInputStream(data);
Tika tika = new Tika();
try {
size = data.length;
contentType = tika.detect(bais);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public InputStream getInputStream() {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(data);
return bais;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String getName() {
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy