Skip to content
Snippets Groups Projects
Select Git revision
  • 46b0a36e8ec6a85bf6480c8c044b40a9710b3fff
  • master default protected
  • dev_2022
  • patch-1
  • develop
  • 50-use-ubuntus-libhidapi
  • issue-highLevelDispatch
  • issue-highLevelDesign
  • issue-motorStartBug
  • issue-commandLayerDesign
  • v1.0
  • v0.4-rc.13
  • v0.4-rc.12
  • v0.4-rc.11
  • v0.4-rc.10
  • v0.4-rc.9
  • v0.3-rc.8
  • v0.3-rc.7
  • v0.3-rc.6
  • v0.3-rc.5
  • v0.3-rc.4
  • v0.3-rc.3
  • v0.3-rc.2
  • v0.3-rc.1
  • v0.3-rc
  • v0.2
  • v0.1.1
  • v0.1
28 results

OutputStreamSend.java

Blame
    • ='s avatar
      a8517f1a
      Initial commit · a8517f1a
      = authored
      Adds the beta-version of the toolbox along with examples, a How-To and
      convenient documents.
      a8517f1a
      History
      Initial commit
      = authored
      Adds the beta-version of the toolbox along with examples, a How-To and
      convenient documents.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    OutputStreamSend.java 1.00 KiB
    import java.io.*;
    
    public class OutputStreamSend {
      public static byte[] buffer = null;
      public static int counter = 0;
    
      public OutputStreamSend(int length) {
        buffer = new byte[length];
        clear();
      }
    
      public OutputStreamSend() {
        this(128);
      }
      
      public void addtoBuffer(char v) {
          buffer[counter] = (byte)v;
          counter++;
      }
      
      public void addtoBufferN(char[] v, int len) {
            for(int i=0; i<len; i++)
            {
                buffer[counter] = (byte)v[i];
                counter++;
            }
      }
      
      public void display() {
          for(int i=0;i<counter;i++)
          {
            System.out.print(buffer[i]);
          }
      }
      
      public void clear() {
           for(int i=0;i<counter;i++)
          {
            buffer[i] = 0;
          }
          counter = 0;
      }
    
      public void send(OutputStream output) throws IOException {
          try {
            output.write(buffer,0,counter);
    		output.flush();
            this.clear();
                
          } catch (Exception e) {}
      }
    
    }