<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to encode a zip file using Base64 and write the encoded string output into a file in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-encode-a-zip-file-using-Base64-and-write-the-encoded/m-p/2294722#M67569</link>
    <description>&lt;P&gt;Need help on steps to encode a zip file to Base64&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2018 02:49:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-02-28T02:49:24Z</dc:date>
    <item>
      <title>How to encode a zip file using Base64 and write the encoded string output into a file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-encode-a-zip-file-using-Base64-and-write-the-encoded/m-p/2294722#M67569</link>
      <description>&lt;P&gt;Need help on steps to encode a zip file to Base64&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 02:49:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-encode-a-zip-file-using-Base64-and-write-the-encoded/m-p/2294722#M67569</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-28T02:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to encode a zip file using Base64 and write the encoded string output into a file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-encode-a-zip-file-using-Base64-and-write-the-encoded/m-p/2294723#M67570</link>
      <description>&lt;P&gt;This routine will help you. I wrote this a while ago for something I was doing at the time. Not used it in a while, but believe it should work for you. You will need the org.apache.commons.codec Jar and will need to set it as a routine library. After you have done that, this will work for you.&lt;/P&gt; 
&lt;PRE&gt;package routines;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.commons.codec.binary.Base64;

/*
 * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
 * it must be before the "{talendTypes}" key.
 * 
 * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
 * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
 * Short
 * 
 * 3. {Category} define a category for the Function. it is required. its value is user-defined .
 * 
 * 4. {param} 's format is: {param} &amp;lt;type&amp;gt;[(&amp;lt;default value or closed list values&amp;gt;)] &amp;lt;name&amp;gt;[ : &amp;lt;comment&amp;gt;]
 * 
 * &amp;lt;type&amp;gt; 's value should be one of: string, int, list, double, object, boolean, long, char, date. &amp;lt;name&amp;gt;'s value is the
 * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
 * added. you can have many parameters for the Function.
 * 
 * 5. {example} gives a example for the Function. it is optional.
 */
public class Base64Encoding {

    public static String encodeFileToString(String filepath){
        File originalFile = new File(filepath);
        String encodedBase64 = null;
        try {
            FileInputStream fileInputStreamReader = new FileInputStream(originalFile);
            byte[] bytes = new byte[(int)originalFile.length()];
            fileInputStreamReader.read(bytes);
            encodedBase64 = new String(Base64.encodeBase64(bytes));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        
    	return encodedBase64;
    }
    
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 09:45:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-encode-a-zip-file-using-Base64-and-write-the-encoded/m-p/2294723#M67570</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-28T09:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to encode a zip file using Base64 and write the encoded string output into a file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-encode-a-zip-file-using-Base64-and-write-the-encoded/m-p/2294724#M67571</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 11:05:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-encode-a-zip-file-using-Base64-and-write-the-encoded/m-p/2294724#M67571</guid>
      <dc:creator>Guerric_Tessier</dc:creator>
      <dc:date>2022-09-13T11:05:15Z</dc:date>
    </item>
  </channel>
</rss>

