fileio.java

来自「JAVA的CMM编译器(词法+语法+语义+输出结果)」· Java 代码 · 共 41 行

JAVA
41
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package cmm;import java.io.*;import java.util.*;/** * * @author lx */public class FileIO {    public FileIO(){            }    public void writeIns(LinkedList instruc) throws IOException{        PrintWriter  output =            new  PrintWriter(new FileWriter("D:\\Instruc.txt"));                while(!instruc.isEmpty()){            Instruction temp;            temp = (Instruction)instruc.poll();            String ins = temp.getIns().toString();            int lev = temp.getLev();            String a;            if(temp.getFlag()){                a = String.valueOf( temp.getA_r());            }else{                a = String.valueOf(temp.getA_i());            }            output.println(ins +"      "+ lev + "      " + a);        }        output.println("完成目标代码生成!");        output.close();    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?