本文整理了Java中org.apache.pdfbox.io.IOUtils.closeQuietly()
方法的一些代码示例,展示了IOUtils.closeQuietly()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.closeQuietly()
方法的具体详情如下:
包路径:org.apache.pdfbox.io.IOUtils
类名称:IOUtils
方法名:closeQuietly
[英]Null safe close of the given Closeable suppressing any exception.
[中]给定可关闭对象的空安全关闭,禁止任何异常。
代码示例来源:origin: apache/pdfbox
public ByteArrayDataSource(InputStream is) throws IOException
{
data = new ByteArrayOutputStream();
IOUtils.copy(is, data);
IOUtils.closeQuietly(is);
}
代码示例来源:origin: apache/pdfbox
private File createTmpFile(InputStream input) throws IOException
{
File tmpFile = File.createTempFile(TMP_FILE_PREFIX, ".pdf");
try (FileOutputStream fos = new FileOutputStream(tmpFile))
{
IOUtils.copy(input, fos);
return tmpFile;
}
finally
{
IOUtils.closeQuietly(input);
}
}
代码示例来源:origin: apache/pdfbox
private static List<File> listFiles(String path) throws IOException
{
List<File> files = new ArrayList<>();
File f = new File(path);
if (f.isFile())
{
FileReader fr = new FileReader(f);
BufferedReader buf = new BufferedReader(fr);
while (buf.ready())
{
File fn = new File(buf.readLine());
if (fn.exists())
{
files.add(fn);
} // else warn ?
}
IOUtils.closeQuietly(buf);
}
else
{
File[] fileList = f.listFiles();
if (fileList != null)
{
files.addAll(Arrays.asList(fileList));
}
}
return files;
}
}
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(output);
IOUtils.closeQuietly(input);
代码示例来源:origin: apache/pdfbox
/**
* This will parse the stream and populate the COSDocument object.
*
* @throws IOException If there is an error reading from the stream or corrupt data
* is found.
*/
public void parse() throws IOException
{
// set to false if all is processed
boolean exceptionOccurred = true;
try
{
if (!parseFDFHeader())
{
throw new IOException( "Error: Header doesn't contain versioninfo" );
}
initialParse();
exceptionOccurred = false;
}
finally
{
if (exceptionOccurred && document != null)
{
IOUtils.closeQuietly(document);
document = null;
}
}
}
}
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(is);
is = new ByteArrayInputStream(os.toByteArray());
os.reset();
代码示例来源:origin: apache/pdfbox
/**
* Returns the contents of the stream as a PDF "text string".
*/
public String toTextString()
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream input = null;
try
{
input = createInputStream();
IOUtils.copy(input, out);
}
catch (IOException e)
{
LOG.debug("An exception occured trying to get the content - returning empty string instead", e);
return "";
}
finally
{
IOUtils.closeQuietly(input);
}
COSString string = new COSString(out.toByteArray());
return string.getString();
}
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(out);
if (ios != null)
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(document);
document = null;
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(randomAccess);
randomAccess = scratchFile.createBuffer();
OutputStream out = new RandomAccessOutputStream(randomAccess);
代码示例来源:origin: apache/pdfbox
final int[] readCIDToGIDMap() throws IOException
{
int[] cid2gid = null;
COSBase map = dict.getDictionaryObject(COSName.CID_TO_GID_MAP);
if (map instanceof COSStream)
{
COSStream stream = (COSStream) map;
InputStream is = stream.createInputStream();
byte[] mapAsBytes = IOUtils.toByteArray(is);
IOUtils.closeQuietly(is);
int numberOfInts = mapAsBytes.length / 2;
cid2gid = new int[numberOfInts];
int offset = 0;
for (int index = 0; index < numberOfInts; index++)
{
int gid = (mapAsBytes[offset] & 0xff) << 8 | mapAsBytes[offset + 1] & 0xff;
cid2gid[index] = gid;
offset += 2;
}
}
return cid2gid;
}
}
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(out);
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(scratchFile);
throw ioe;
IOUtils.closeQuietly(raFile);
throw ioe;
代码示例来源:origin: apache/tika
org.apache.pdfbox.io.IOUtils.closeQuietly(data);
} else {
InputStream data = pdImage.createInputStream(JP2);
org.apache.pdfbox.io.IOUtils.copy(data, out);
org.apache.pdfbox.io.IOUtils.closeQuietly(data);
} else if ("jb2".equals(suffix)) {
InputStream data = pdImage.createInputStream(JB2);
org.apache.pdfbox.io.IOUtils.copy(data, out);
org.apache.pdfbox.io.IOUtils.closeQuietly(data);
} else{
ImageIOUtil.writeImage(image, suffix, out);
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(keyStoreStream);
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(input);
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(source);
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(randomAccess);
randomAccess = scratchFile.createBuffer();
OutputStream randomOut = new RandomAccessOutputStream(randomAccess);
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(scratchFile);
throw ioe;
代码示例来源:origin: apache/pdfbox
IOUtils.closeQuietly(is);
int numberOfInts = mapAsBytes.length / 2;
cid2gid = new Object[numberOfInts][4];
内容来源于网络,如有侵权,请联系作者删除!