Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
PETALS - PETALS Services Platform. Copyright (c) 2010 EBM WebSourcing - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A data source which contains a file content.

This class works like FileDataSource, but does not require the file to still exist when getInputStream() is called.

Vincent Zurczak - EBM WebSourcing
 public class FileContentDataSource implements DataSource {

The file name.
 	private final String name;

The file content.
 	private final byte[] fileCcontent;


file the file to load
Throws: if the file could not be loaded
 	public FileContentDataSourceFile file ) throws IOException {
 		FileInputStream fis = new FileInputStreamfile );
 		int size = Long.valueOffile.length()).intValue();
         try {
         } finally {
 		this. = file.getName();
 		this. = bos.toByteArray();
 	/* (non-Javadoc)
 	 * @see javax.activation.DataSource#getContentType()
 	public String getContentType() {
 		return "application/octet-stream";
 	/* (non-Javadoc)
 	 * @see javax.activation.DataSource#getInputStream()
 	public InputStream getInputStream() throws IOException {
 		return new ByteArrayInputStreamthis. );
 	/* (non-Javadoc)
 	 * @see javax.activation.DataSource#getName()
 	public String getName() {
 		return this.;
	/* (non-Javadoc)
	 * @see javax.activation.DataSource#getOutputStream()
		TalendUtils.copyStreamgetInputStream(), os );
		return os;
New to GrepCode? Check out our FAQ X