代码:import java.io.*;
import java.io.File.*;
import java.awt.*;
import java.awt.event.*;public class OK extends Frame implements ActionListener
{
public Label lAddress;
public Label lFormer;
public Label lLatter;
public TextField tfOK;
public Button bOK;
public TextField tfFormer;
public TextField tfLatter;
public TextField tfAddress; public OK(String s)
{
super(s);
lAddress=new Label("文件夹:");
tfAddress=new TextField(18);
lFormer=new Label("原来的扩展名:");
tfFormer=new TextField(18);
lLatter=new Label("改成的扩展名:");
tfLatter=new TextField(18);
bOK=new Button("确定");
setLayout(new GridLayout(8,1));
add(lAddress);
add(tfAddress);
add(lFormer);
add(tfFormer);
add(lLatter);
add(tfLatter);
add(bOK);
add(tfOK);
bOK.addActionListener(this);
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
}
public void actionPerformed(ActionEvent e)
{
if(tfAddress.getText()==null)
{
tfOK.setText("无有效文件夹。");
System.exit(0);
}
else
{
File n=new File(tfAddress.getText());
/*if(!n.exist())
{
tfOK.setText("不是有效的文件夹。");
System.exit(0);
}*/
if(tfFormer.getText()==null||tfLatter.getText()==null)
//||(!(tfFormer.getText().startWith(".")))||(!(tfLatter.getText().startWith("."))))
{
tfOK.setText("文件格式不明确。");
System.exit(0);
} File flDir=new File(tfAddress.getText());
String [] files =flDir.list();
for(int i=0;i<files.length;i++)
{
File flTemp=new File(files[i]);
String s=new String(files[i]);
if(flTemp.isDirectory())
continue;
String str=s.subSting(1,9);
String name=str.concat(tfLatter.getText());
File newName=new File (name);
flTemp.renameTo(newName);
} tfOK.setText("完成!");
} public static void main(String [] args)
{
OK o=new OK("批量改扩展名");
o.setVisible(true);
};
}
}提示错误:C:\JBuilder6\jdk1.3.1\bin>javac OK.java
OK.java:78: illegal start of expression
public static void main(String [] args)
^
OK.java:69: cannot resolve symbol
symbol : method subSting (int,int)
location: class java.lang.String
String str=s.subSting(1,9);
^
2 errors
import java.io.File.*;
import java.awt.*;
import java.awt.event.*;public class OK extends Frame implements ActionListener
{
public Label lAddress;
public Label lFormer;
public Label lLatter;
public TextField tfOK;
public Button bOK;
public TextField tfFormer;
public TextField tfLatter;
public TextField tfAddress; public OK(String s)
{
super(s);
lAddress=new Label("文件夹:");
tfAddress=new TextField(18);
lFormer=new Label("原来的扩展名:");
tfFormer=new TextField(18);
lLatter=new Label("改成的扩展名:");
tfLatter=new TextField(18);
bOK=new Button("确定");
setLayout(new GridLayout(8,1));
add(lAddress);
add(tfAddress);
add(lFormer);
add(tfFormer);
add(lLatter);
add(tfLatter);
add(bOK);
add(tfOK);
bOK.addActionListener(this);
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
}
public void actionPerformed(ActionEvent e)
{
if(tfAddress.getText()==null)
{
tfOK.setText("无有效文件夹。");
System.exit(0);
}
else
{
File n=new File(tfAddress.getText());
/*if(!n.exist())
{
tfOK.setText("不是有效的文件夹。");
System.exit(0);
}*/
if(tfFormer.getText()==null||tfLatter.getText()==null)
//||(!(tfFormer.getText().startWith(".")))||(!(tfLatter.getText().startWith("."))))
{
tfOK.setText("文件格式不明确。");
System.exit(0);
} File flDir=new File(tfAddress.getText());
String [] files =flDir.list();
for(int i=0;i<files.length;i++)
{
File flTemp=new File(files[i]);
String s=new String(files[i]);
if(flTemp.isDirectory())
continue;
String str=s.subSting(1,9);
String name=str.concat(tfLatter.getText());
File newName=new File (name);
flTemp.renameTo(newName);
} tfOK.setText("完成!");
} public static void main(String [] args)
{
OK o=new OK("批量改扩展名");
o.setVisible(true);
};
}
}提示错误:C:\JBuilder6\jdk1.3.1\bin>javac OK.java
OK.java:78: illegal start of expression
public static void main(String [] args)
^
OK.java:69: cannot resolve symbol
symbol : method subSting (int,int)
location: class java.lang.String
String str=s.subSting(1,9);
^
2 errors
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货