Hola buenas tardes no se si no formule bien mi pregunta o si no esta hecha aun, pero aqui voy. Estoy realizando un programa en JAVA que como tal revise un archivo de texto que contiene instrucciones en ASM sin embargo lo que yo busco como tal es borrar ciertas partes del codigo ASM no toda la linea, Me explico. tengo este codigo:
; ===== CONTROL THE TRAFFIC LIGHTS =============================
CLO ; Close unwanted windows.
Start:
; Turn off all the traffic lights.
MOV AL,0 ; Copy 00000000 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
; Turn on all the traffic lights.
MOV AL,FC ; Copy 11111100 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
JMP Start ; Jump back to the start.
END ; Program ends.
; ===== Program Ends ==========================================
YOUR TASK
=========
Use the help page on Hexadecimal and ASCII codes.
Work out what hexadecimal numbers will activate the
correct traffic lights. Modify the program to step
the lights through a realistic sequence.
y lo que deseo es borrar todo rastro de comentarios, esto con el fin de limpiar el código original y que quede de la siguiente manera:
CLO
Start:
MOV AL,0
OUT 01
MOV AL,FC
OUT 01
JMP Start
END
tengo parte de mi código java que ya realiza la funcion de limpiar algunas lineas, sin embargo la parte que se me esta dificultando es la que debo borrar el resto de la linea despues de encontrar un ";" y un "END" que son precisamente los que marcan el inicio de un comentario y el fin del código. ahora la parte de código que limpia es la siguiente:
while((linea=br.readLine())!=null){
linea = linea.trim();
if(linea.length()>0){
if(!linea.startsWith(";")){
System.out.println(linea);
pw.println(linea);
}
if(!linea.contains(";")){
pw.print("");
}
}
}
sin embargo no se que es lo debo hacer para eliminar el resto. tengo la idea de que es con esta parte del codigo que dicta:
if(!linea.contains(";")){
pw.EliminaContenido;
}
Espero alguien me pueda orientar. muchas gracias