package com.yyq; import java.io.*; /* * 装饰类(带行号的装饰类) */ public class LineNumberReaderDemo { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub LineNumberReader lnbr = new LineNumberReader(new FileReader("1.txt")); String line = null; //lnbr.setLineNumber(111); while((line = lnbr.readLine())!=null){ System.out.println(lnbr.getLineNumber()+":"+line); } } }