`
shoukii0721
  • 浏览: 78222 次
社区版块
存档分类
最新评论

修改Eclipse启动图片

    博客分类:
  • Java
阅读更多
import java.io.File; 
import java.util.ArrayList; 
import java.util.List; 
import java.util.Random; 
 
public class RunEclipse { 
 
    private static String picFolder = "mysplash"; 
 
    /**
     * @param args
     * @throws Exception
     */ 
    public static void main(String[] args) throws Exception { 
 
        makeFolder(picFolder); 
 
        String runString = "eclipse.exe -showsplash "; 
        runString += picFolder; 
        runString += "\\"; 
        runString += getShowPictureName(picFolder); 
 
        Runtime rt = Runtime.getRuntime(); 
        rt.exec(runString); 
 
    } 
 
    private static void makeFolder(String folder) { 
        File file = new File(folder); 
        if (!file.exists()) { 
            file.mkdir(); 
        } 
    } 
 
    /**
     * @param args
     */ 
    private static String getShowPictureName(String filePath) { 
 
        int picCount = 0; 
        List<String> picList = new ArrayList<String>(); 
        String strRun = ""; 
 
        File file = new File(filePath); 
 
        if (file.isDirectory()) { 
            String[] filelist = file.list(); 
 
            for (int i = 0; i < filelist.length; i++) { 
                if (filelist[i].toLowerCase().endsWith(".bmp")) { 
                    picCount++; 
                    picList.add(filelist[i]); 
                } 
            } 
 
            if (picCount > 0) { 
                Random rand = new Random(); 
                int index = rand.nextInt(picCount); 
                strRun = filelist[index]; 
            } 
        } 
 
        return strRun; 
    } 
 
}  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics