Problems writing to unix feed through Java

I write to the framebuffer located at / dev / fb 0. Everything works fine until I try again to write the handset using an OutputStream, which is program dependent. I solved this by closing the output stream and then recreating it, but it seems terribly slow and dumb.

Framebuffer.java

public class Framebuffer extends Autobuffer {
private FileOutputStream out = null;
private File pipe = null;

public Framebuffer() {
   super(320, 240);
}

public Framebuffer(File pipe) {
   super(320, 240);
   try {
      out = new FileOutputStream(pipe);
   } catch (FileNotFoundException e) {
   e.printStackTrace();
  }
 this.pipe = pipe;
 }

 public void sync() throws IOException {
   out.write(getBytes());
   out.close();
   out = new FileOutputStream(pipe);
 }
 }

code>

Any ideas?

Thank.

+3
source share
3 answers

Firstly, if something really strange is not happening, "/ dev / fb0" is the device file, not the channel. [This is nitpick, but if you use the wrong terminology, 1) people will not understand you, and 2) it will be difficult for you to find the answers.]

Secondly, it looks like a weird way to interact with the framebuffer !!

, , POSIX lseek, , . :

+2

RandomAccessFile . , , 0. , .

+1

, flush ( OutputStream)?

0

Source: https://habr.com/ru/post/1730711/


All Articles