java新手代码翻译成中文_急!老师让我把以下代码翻译成中文的

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.saveMenuItemActionPerformed(evt);

}

}

// 定义另存为事件类

class saveAsMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

saveAsMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.saveAsMenuItemActionPerformed(evt);

}

}

// 定义页面设置事件类

class pageSetupMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

pageSetupMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.pageSetupMenuItemActionPerformed(evt);

}

}

// 定义打印事件类

class printMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

printMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.printMenuItemActionPerformed(evt);

}

}

// 定义Java风格事件类

class javaStyleMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

javaStyleMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.javaStyleMenuItemActionPerformed(evt);

}

}

// 定义Java风格事件类

class metalStyleMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

metalStyleMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.metalStyleMenuItemActionPerformed(evt);

}

}

// 定义Java风格事件类

class windowsStyleMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

windowsStyleMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.windowsStyleMenuItemActionPerformed(evt);

}

}

// 定义帮助主题事件类

class helpTopicMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

helpTopicMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.helpTopicMenuItemActionPerformed(evt);

}

}

// 定义关于软件事件类

class aboutMenuItem_actionAdapter implements ActionListener{

Notepad adaptee;

aboutMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.aboutMenuItemActionPerformed(evt);

}

}

// 定义退出事件类

class exitMenuItem_actionAdapter implements ActionListener   {

Notepad adaptee;

exitMenuItem_actionAdapter(Notepad adaptee){

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent evt){

adaptee.exitMenuItem_actionPerformed(evt);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
大多源码来自互联网,本人只做部分正和 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import com.vince.*; /** * 将本地文件以哪种编码输出 * @param inputfile 输入文件的路径 * @param outfile 输出文件的路径 * @param code 输出文件的编码 * @throws IOException */ public class Charchange{ public static void main(String[] args) throws IOException { String inputfile,outputfile,code; inputfile = "D:\\迅雷\\work\\fen\\2-temp-test.txt";//要转码的文件 outputfile = "D:\\迅雷\\work\\1.txt";//输出的文件 code = "utf-8"; System.out.println("转码开始"); convert(inputfile,outputfile,code); System.out.println("转码完成"); } public static void convert(String inputfile,String outfile,String code) throws IOException { StringBuffer sb = new StringBuffer(); StringBuffer sb2 = new StringBuffer(); //得到当前文件的编码 String ch=getCharset(inputfile); InputStreamReader isr=null; OutputStreamWriter osw =null; //根据当前文件编码进行解码 if(ch.equals("UTF8")){ isr= new InputStreamReader(new FileInputStream(inputfile), "UTF-8"); }else if(ch.equals("Unicode")){ isr= new InputStreamReader(new FileInputStream(inputfile), "Unicode"); }else { isr= new InputStreamReader(new FileInputStream(inputfile), "GB2312"); } //将字符串存入StringBuffer中 BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); isr.close(); //以哪种方式写入文件 if("UTF-8".equals(code)){ osw = new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8"); }else if("GB2312".equals(code)){ osw = new OutputStreamWriter(new FileOutputStream(outfile), "GB2312"); }else if("Unicode".equals(code)){ osw = new OutputStreamWriter(new FileOutputStream(outfile), "Unicode"); }else{ osw = new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8"); } BufferedWriter bw = new BufferedWriter(osw); String sb1 = sb.toString(); String a1 = deal(sb1); bw.write(a1); bw.close(); osw.close(); } /** * 根据文件路径判断编码 * @param str * @return * @throws IOException */ private static String getCharset(String str) throws IOException{ BytesEncodingDetect s = new BytesEncodingDetect(); String code = BytesEncodingDetect.javaname[s.detectEncoding(new File(str))]; return code; } //本方法完成单个无字符的转换 public static String Change(String temp){ String myString = temp.replace("&#", ""); String[] split = myString.split(";"); StringBuilder sb = new StringBuilder(); for (int i = 0; i < split.length; i++) { sb.append((char)Integer.parseInt(split[i])); } return sb.toString(); } //接收String sb1并对字符串的联合处理 public static String deal(String sb1) { //模块化开始 String car="";//小车运输单个字符 while(sb1.length()!=0){ int markStar = sb1.indexOf("&"); //判断方法是以&开头的数据默认为要处理的无字符 if(markStar==0){ String temp = sb1.substring(markStar,8); car = car+Change(temp); sb1=sb1.substring(8); }else if(markStar==-1&sb1;.length()>0){ String temp = sb1.substring(0,sb1.length()); car = car+temp; sb1=sb1.substring(sb1.length()); }else{ String temp = sb1.substring(0,markStar); car = car+temp; sb1=sb1.substring(markStar); } } return car.toString() ; } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值