001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.component.file.remote;
018    
019    import java.io.ByteArrayInputStream;
020    import java.io.ByteArrayOutputStream;
021    import java.io.InputStream;
022    
023    import org.apache.camel.Converter;
024    
025    /**
026     * A set of converter methods for working with remote file types
027     *
028     * @version $Revision: 680078 $
029     */
030    @Converter
031    public final class RemoteFileConverter {
032        
033        private RemoteFileConverter() {
034            // Helper Class
035        }
036    
037        @Converter
038        public static byte[] toByteArray(ByteArrayOutputStream os) {
039            return os.toByteArray();
040        }
041    
042        @Converter
043        public static String toString(ByteArrayOutputStream os) {
044            return os.toString();
045        }
046    
047        @Converter
048        public static InputStream toInputStream(ByteArrayOutputStream os) {
049            return new ByteArrayInputStream(os.toByteArray());
050        }
051    
052    }