Ramses de Norre
February 28th, 2007, 03:21 PM
Yesterday I was shown the concept of named pipes (also called fifos), but it seems that java can't handle them?
I made a fifo in my home directory with mkfifo clip and wrote a little script to link a purpose to it:
#!/bin/bash
LOC=/home/ramses/clip
if [ -p $LOC ]
then
while(true)
do
xclip -in < $LOC > out
done
else
echo "$LOC doesn't exist or is no named pipe, exiting"
exit 1
fi
This all works perfect, but now the problem:
When I write this in java:
PrintWriter pW=new PrintWriter(new BufferedOutputStream(new FileOutputStream(new File("/home/ramses/clip")))); the application just hangs on that line... No extensive cpu load, no exceptions, just nothing...
If I create just an OutputStream it works, but not with a PrintWriter.
The same line does work on a regular file.
Anyone who can explain this and maybe knows a workaround?
And the file permissions are set to 777 so that isn't the problem, I can also perfectly write to it from the command line.
I made a fifo in my home directory with mkfifo clip and wrote a little script to link a purpose to it:
#!/bin/bash
LOC=/home/ramses/clip
if [ -p $LOC ]
then
while(true)
do
xclip -in < $LOC > out
done
else
echo "$LOC doesn't exist or is no named pipe, exiting"
exit 1
fi
This all works perfect, but now the problem:
When I write this in java:
PrintWriter pW=new PrintWriter(new BufferedOutputStream(new FileOutputStream(new File("/home/ramses/clip")))); the application just hangs on that line... No extensive cpu load, no exceptions, just nothing...
If I create just an OutputStream it works, but not with a PrintWriter.
The same line does work on a regular file.
Anyone who can explain this and maybe knows a workaround?
And the file permissions are set to 777 so that isn't the problem, I can also perfectly write to it from the command line.