Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package fromgcodetocartesian;
- import static com.sun.xml.internal.bind.v2.schemagen.Util.equal;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- /**
- *
- * @author sirine
- */
- public class FromGcodeToCartesian {
- /**
- * @param args the command line arguments
- */
- static void getCartesian(String expression_Initiale){
- if(equal(expression_Initiale.substring(0,3),"G01")
- ||equal(expression_Initiale.substring(0,3),"G02")
- ||equal(expression_Initiale.substring(0,3),"G03")
- ||equal(expression_Initiale.substring(0,3),"G04")){
- if(expression_Initiale.charAt(4)=='X'||expression_Initiale.charAt(4)=='Y'){
- String X = expression_Initiale.substring(5,10);
- Double XPrime = Double.parseDouble(X);
- String Y = expression_Initiale.substring(12,17);
- Double YPrime = Double.parseDouble(Y);
- System.out.println("(X="+XPrime+",Y="+YPrime+")");
- //Create the point and add it to the object
- }}
- }
- public static void main(String[] args) {
- // TODO code application logic here
- BufferedReader reader;
- try{
- reader=new BufferedReader(new FileReader("/Users/apple/Desktop/IP.txt"));
- String line = reader.readLine();
- while(line!=null){
- getCartesian(line);
- //read the next line
- line = reader.readLine();
- }
- reader.close();
- }catch(IOException e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement