在JAVA中下载网站复印机项目

Website Copier是一个用于下载完整网站以供脱机浏览的应用程序,类似于HTTRACK。完整的源代码是用Java编写的,带有完整的源代码和报告。作者使用Java.Net软件包编写了出色的Java代码。

应用介绍

Website Copier是一个用于下载完整网站以供脱机浏览的应用程序,类似于HTTRACK。完整的源代码是用Java编写的,带有完整的源代码和报告。作者使用Java.Net软件包编写了出色的Java代码。 

package minicopier;
import java.util.*;
import java.io.*;
import minicopier.gui.DialogMsg;
public class Configuration {
 
 private static final String configName = "configuration.ini";
 
 public static String language;
 
 public static boolean alwaysOnTop;
 
 //Look And Feel
 //"pgs" (default)
 //"native"
 //"metal"
 public static String lookAndFeel;
 
 //What to do if destination file already exists
 // 0 -> ask user
 // 1 -> ignore
 // 2 -> overwrite
 // 3 -> overwrite if older
 // 4 -> resume
 // 5 -> rename
 public static int collisionAction;
 
 //What to do if a source path contains a symbolic link
 //(Unix systems only)
 // 0 -> follow
 // 1 -> ignore
 public static int symbolicLinkAction;
    
    //Is speed limit active?
    public static boolean limitSpeed;
    
    //Maximum throughput of the transfer
    public static int nbBytesPerS;
    
    private static boolean firstLaunch = false;
 
 public Configuration(){
        
        this.limitSpeed = false;
        
        this.nbBytesPerS = 1024*1024;
  
  Properties prop = new Properties(); 
  
  File configFile = new File(configName);
  
  if (!configFile.exists()) {
   System.out.println("Configuration file not found. Creating configuration.ini.");
   createConfigFile();
   firstLaunch = true;
  }
  
  try {
   FileInputStream in = new FileInputStream(configName);
   prop.load(in);
   in.close(); 
  } catch (Exception e){
   e.printStackTrace();
  }
  
  setProp(prop);
  
 }
 
 public static void setProp(Properties prop){
  
  String readProp;
  
  //Language
  readProp = prop.getProperty("language");
  if (("").equals(readProp)||(readProp==null)){
   language = "SystemLocale";
  } else {
   language = readProp;
  }
  
  //Always on top
  readProp = prop.getProperty("alwaysontop");
  if (("true").equals(readProp)){
   alwaysOnTop = true;
  } else {
   alwaysOnTop = false;
  }
  
  //Look an Feel
  readProp = prop.getProperty("lnf");
  if (("").equals(readProp)||(readProp==null)){
   lookAndFeel = "pgs";
  }
  else {
   lookAndFeel = readProp;
  }
  
  //Collision action
  readProp = prop.getProperty("collision");
  if (("ask").equals(readProp)){
   collisionAction = 0;
  } else if (("cancel").equals(readProp)){
   collisionAction = 1;
  } else if (("overwrite").equals(readProp)){
   collisionAction = 2;
  } else if (("overwrite_older").equals(readProp)){
   collisionAction = 3;
  } else if (("resume").equals(readProp)){
   collisionAction = 4;
  } else {
   collisionAction = 0;
  }
  
  //Symbolic links action
  readProp = prop.getProperty("symlinks");
  if (("follow").equals(readProp)){
   symbolicLinkAction = 0;
  } else if (("ignore").equals(readProp)){
   symbolicLinkAction = 1;
  } else {
   symbolicLinkAction = 0;
  }
  
 }
 
 public final void createConfigFile(){
  InputStreamReader isr=new InputStreamReader(getClass()
    .getClassLoader().getResourceAsStream("minicopier/configuration.ini"));
  
  BufferedReader buf = new BufferedReader(isr);
  
  PrintWriter writer;
  String toWrite;
  
  try {
   writer = new PrintWriter (new OutputStreamWriter (new FileOutputStream (configName)));
   while ((toWrite=buf.readLine())!=null){
    writer.println(toWrite);
   }
   buf.close();
   writer.close();
  } catch (Exception e){
   System.out.println("Error creation configuration file !");
  }
  
 }
 
 public boolean wasFirstLaunch(){
  return this.firstLaunch;
 }
    
    public synchronized static void setSpeedValue(int i){
        Configuration.nbBytesPerS = i;
    }
    
    public synchronized static int getSpeedValue(){
        return Configuration.nbBytesPerS;
    }
 
}

文件列表(部分)

名称 大小 修改日期
minicopier-master0.00 KB2009-08-00
ABOUT3.12 KB2009-08-00
LICENSE17.57 KB2009-08-00
Manifest.txt0.06 KB2009-08-00
MiniCopier.sh0.12 KB2009-08-00
README.md1.30 KB2009-08-00
build.xml1.02 KB2009-08-00
lib0.00 KB2009-08-00
PgsLookAndFeel.jar146.96 KB2009-08-00
src0.00 KB2009-08-00
img0.00 KB2009-08-00
alt0.00 KB2009-08-00
cancel.png0.89 KB2009-08-00
down.png0.93 KB2009-08-00
first.png0.96 KB2009-08-00
last.png0.95 KB2009-08-00
up.png0.93 KB2009-08-00
basket.png3.76 KB2009-08-00
delete.gif1.14 KB2009-08-00
down.gif1.00 KB2009-08-00
failed.gif0.92 KB2009-08-00
first.gif1.09 KB2009-08-00
icon.gif0.61 KB2009-08-00
icon.ico44.77 KB2009-08-00
icon.jpg2.95 KB2009-08-00
icon.png1.64 KB2009-08-00
last.gif1.09 KB2009-08-00
list.png0.32 KB2009-08-00
minicopier-logo.png9.32 KB2009-08-00
oldtheme0.00 KB2009-08-00
credits.png0.47 KB2009-08-00
delete.png0.58 KB2009-08-00

立即下载

相关下载

[在JAVA中下载网站复印机项目] Website Copier是一个用于下载完整网站以供脱机浏览的应用程序,类似于HTTRACK。完整的源代码是用Java编写的,带有完整的源代码和报告。作者使用Java.Net软件包编写了出色的Java代码。

评论列表 共有 0 条评论

暂无评论

微信捐赠

微信扫一扫体验

立即
上传
发表
评论
返回
顶部