It's simple!
My concept of pipes were wrong!
You don't need to create the pipe, the TPT creates it for you.
I tried to Read too, but I tried with the wrong Reader class (RandomAccessFile).
My working PipeLoader constructor:
private FileOutputStream pipe;
public PipeLoader() {
while(true) {
try {
getLogger().info("Trying to connect to " + getConnectionUrl());
pipe = new FileOutputStream(getConnectionUrl());
} catch (FileNotFoundException e) {
getLogger().debug(e.getMessage());
}
}
try {
Thread.sleep(6000);
} catch (InterruptedException iExc) {
iExc.printStackTrace();
}
continue;
}
getLogger().info(getConnectionUrl() + " conectado.");
break;
}
My class PipeLoader implements Runnable, and in my run() method I put all my logics and writes:
String line = "";
BufferedReader br = ...
while((line = br.readLine()) != null) {
pipe.write(line.getBytes());
pipe.write("\n".getBytes());
}
Obs.: I can create the pipe from Java using JNI, but maybe, I never will use this.
Is this.
↧