Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
gt0731
Contributor III
Contributor III

How to call and test Custom java code in talend

Hi Everyone, 

We would like to try following a custom java code using talend. 

I stuck in following java code using java components. I am new to the component testing for java code

Also, I would like to make sure below code tested well before to put in a routine section 

We tried 

below post as well 

https://www.talendbyexample.com/talend-tjavaflex-component-reference.html

it did not work for me 

Here is Input code  

 

Split file based on size

   

import java.io.FileInputStream;
import java.io.FileOutputStream;

class FileSplitter {

  public static void main(String args[]) throws Exception {
    FileInputStream fis = new FileInputStream(args[0]);
    int size = 1024;
    byte buffer[] = new byte[size];

    int count = 0;
    while (true) {
      int i = fis.read(buffer, 0, size);
      if (i == -1)
        break;

      String filename = args[1] + count;
      FileOutputStream fos = new FileOutputStream(filename);
      fos.write(buffer, 0, i);
      fos.flush();
      fos.close();

      ++count;
    }
  }
}

   
    
    
  

 

Any help would be much appreciated 

 

How to test above code in tJava /tJavaFlex  before putting into  routines. ?

 

 

Labels (3)
0 Replies