求高手点拨:“一个Java程序中的小错误”的错误原因....
高手,您好:
我是一名学习软件工程的学生,今天在调试程序的时候,我发现了一个错误:
错误类的代码截图如下:

错误类的代码如下:
package c_port_package;
import java.io.File;
import java.net.Socket;
public class TheSyslegalUserConfirm{
static String MyOrderNum = null;
static int i = 0;
static int j = 0;
Socket so1 = null;
File file1 = new File("C:\\");
File file2 = new File("D:\\");
File file3 = new File("E:\\");
File file4 = new File("D:\\");
static File[] fileArray0 = new File[i];
static File[] fileArray1 = new File[j];
String[] commonfruit = null;
String[] videofruit = null;
static String sector = null;
CheckAndConfirmworker checkworker = new CheckAndConfirmworker();
public TheSyslegalUserConfirm(){
CheckAndConfirmworker.findthecommonfruit(file1);
CheckAndConfirmworker.findthevideofruit(file1);
CheckAndConfirmworker.findthecommonfruit(file2);
CheckAndConfirmworker.findthevideofruit(file2);
CheckAndConfirmworker.findthecommonfruit(file3);
CheckAndConfirmworker.findthevideofruit(file3);
CheckAndConfirmworker.findthecommonfruit(file4);
CheckAndConfirmworker.findthevideofruit(file4);
i = commonfruit.length;
j = videofruit.length;
for(int x=0;x<commonfruit.length;x++){
fileArray0[x] = new File(commonfruit[x]);
}
for(int y=0;y<videofruit.length;y++){
fileArray1[y] = new File(videofruit[y]);
}
}
}
其中的“CheckAndConfirmworker”类的类头的截图如下:

其中的“CheckAndConfirmworker”类的第22行的出错的方法“findthecommonfruit(file)”,的方法定义的方法头的截图内容如下:

这里的“CheckAndConfirmworker”类文件的代码如下:
package c_port_package;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
public class CheckAndConfirmworker {
static C_port_Our_honor fileDS = null;
HashMap<String,String> fileset = null;
static ArrayList<String> thecommonfruitPath = new ArrayList<String>();
static ArrayList<String> thevideofruitPath = new ArrayList<String>();
static ArrayList<String> thecommonfruitFullname = new ArrayList<String>();
static ArrayList<String> thecommonfruitExtenName = new ArrayList<String>();
static ArrayList<String> thecommonfruitpreName = new ArrayList<String>();
static ArrayList<String> thecommonvideoExtenName = new ArrayList<String>();
static ArrayList<String> thevideoFullName = new ArrayList<String>();
static ArrayList<String> thevideofruitpreName = new ArrayList<String>();
static ArrayList<String> thevideofruitFullName = new ArrayList<String>();
static ArrayList<String> thevideofruitExtenName = new ArrayList<String>();
static int calc0 = 0;
static int calc1 = 0;
static File file = new File("D:\\");
static int j = 0;
static int t = 1;
//获取文件扩展名
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf('.');
if ((dot >-1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
//获取去掉扩展名的文件名
public static String getpreFileName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf('.');
if ((dot >-1) && (dot < (filename.length()))) {
return filename.substring(0, dot);
}
}
return filename;
}
public static void main(String[] args){
//thecommonfruitPath = findthecommonfruit(file);
findthecommonfruit(file);
for(int i = 0;i<calc0 ;i++){
System.out.println(thecommonfruitExtenName.get(i));
}
}
static public void findthecommonfruit(File file){
File[] files1 = null;
files1 = file.listFiles();
if(files1==null||files1.length==0){
return ;
}
for(int i=0;i<files1.length;i++){
if(files1[i].isDirectory()){
findthecommonfruit(files1[i]);
}
for(i=0;i<files1.length;i++){
if(files1[i].isDirectory()){
findthevideofruit(files1[i]);
}
//System.out.println(files[i]);
else if(files1[i].getPath().endsWith("ppt")||files1[i].getPath().endsWith("doc")||files1[i].getPath().endsWith("txt")||files1[i].getPath()
.endsWith("wps")||files1[i].getPath().endsWith("excel")||files1[i].getPath().endsWith("jude")||files1[i].getPath().endsWith("bmp")
||files1[i].getPath().endsWith("c")||files1[i].getPath().endsWith("cpp")||files1[i].getPath().endsWith("java")||files1[i].getPath().endsWith("js")
||files1[i].getPath().endsWith("asp")||files1[i].getPath().endsWith("jsp")||files1[i].getPath().endsWith("php")||files1[i].getPath().endsWith("pdf")
||files1[i].getPath().endsWith("jpeg")||files1[i].getPath().endsWith("gif")||files1[i].getPath().endsWith("html")||files1[i].getPath().endsWith("png")
||files1[i].getPath().endsWith("xls")||files1[i].getPath().endsWith("zip")){
thecommonfruitPath.add(files1[i].getAbsolutePath());
thecommonfruitFullname.add(files1[i].getName());
thecommonfruitpreName.add(getpreFileName(files1[i].getName()));
thecommonfruitExtenName.add(getExtensionName(files1[i].getName()));
++calc0;
}
}
}
//return thecommonfruitPath;
}
static public void findthevideofruit(File file){
File[] files2 = null;
files2 = file.listFiles();
if(files2 == null){
return;
}
for(int i=0;i<files2.length;i++){
if(files2[i].isDirectory()){
findthecommonfruit(files2[i]);
}
for(i=0;i<files2.length;i++){
if(files2[i].isDirectory()){
findthevideofruit(files2[i]);
}
//System.out.println(files[i]);
else if(files2[i].getPath().endsWith("3GP")||files2[i].getPath().endsWith("mid")||files2[i].getPath().endsWith("mp4")||files2[i].getPath()
.endsWith("flash")||files2[i].getPath().endsWith("rm")||files2[i].getPath().endsWith("rmvb")||files2[i].getPath().endsWith("wma")
||files2[i].getPath().endsWith("avi")){
thevideofruitPath.add(files2[i].getAbsolutePath());
thevideofruitFullName.add(files2[i].getName());
thevideofruitpreName.add(getpreFileName(files2[i].getName()));
thevideofruitExtenName.add(getExtensionName(files2[i].getName()));
++calc1;
}
}
}
//return thevideofruitPath;
}
public static ArrayList<String> giveCsectorcommonFilepath(){
return thecommonfruitPath;
}
public static ArrayList<String> giveCsectorvideoFilepath(){
return null;
}
public static ArrayList<String> giveDsectorcommonFilepath(){
return null;
}
public static ArrayList<String> giveDvideocommonFilepath(){
return null;
}
public static ArrayList<String> giveEsectorcommonfilepath(){
return null;
}
public static ArrayList<String> giveEsectorvideofilepath(){
return null;
}
public static ArrayList<String> giveFsectorcommonfilepath(){
return null;
}
public static ArrayList<String> giveFsectorvideofilepath(){
return null;
}
}
希望高手能够将我的问题的原因,告诉我...
谢谢高手的点拨!!
一百分奉上!!
一位日日夜夜向着梦想奔跑的筑梦者
2013年8月12日中午12点47分 Java Java调试
Java排错
[解决办法]
为什么不直接定位错误信息,错误代码行号?
[解决办法]
你每行前面的》》
还有行末尾的符号都是什么东西啊
全部都去掉啊
[解决办法]
你把鼠标放大出错行钱买你红色的差号上面看一下错误原因,你这个是编译错误,通过这个错误原因提示自己找一下哪里有问题吧
没看到哪里有问题,你把这几行出错的删除掉保存看看有没有错误,然后在ctrl+z,在保存一下,eclipse有时候编译会出问题,报一些莫名其妙的错误,clean一下就好
[解决办法]
文件名字前面还有*号,还没有保存。保存一下,然后调试错误。
[解决办法]
先保存吧,有时候你修改好了,没保存,那个编译错误还是有的。