Advertisement
Guest User

GcodeSender

a guest
Aug 26th, 2016
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. import java.net.*;
  2. import java.io.*;
  3. import java.util.*;
  4.  
  5.  
  6. class GcodeSender {
  7.     public static void main(String[] args)  throws Exception {
  8.         Socket s=new Socket("192.168.1.19",23);
  9.         PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
  10.         Scanner inp = new Scanner(s.getInputStream() );
  11.         File f=new File(args[0]);
  12.         Scanner sc = new Scanner(f);
  13.         int i,j=0;
  14.         while(sc.hasNextLine()) {
  15.                 String line = sc.nextLine().trim();
  16.                 if(line.startsWith("(") || line.startsWith(";") || line.length()==0) continue;
  17.                 if((i=line.indexOf(";"))>0) line=line.substring(0,i);
  18.                 pw.println( line ); System.out.print(++j+"> "+ line+" : " );
  19.                 do {
  20.                         line = inp.nextLine();
  21.                         System.out.println(line);
  22.                 } while(!line.equals("ok"));
  23.  
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement