在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;
}
}
©版权声明:本文内容由互联网用户自发贡献,版权归原创作者所有,本站不拥有所有权,也不承担相关法律责任。如果您发现本站中有涉嫌抄袭的内容,欢迎发送邮件至: www_apollocode_net@163.com 进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。
转载请注明出处: apollocode » 在JAVA中下载网站复印机项目
文件列表(部分)
名称 | 大小 | 修改日期 |
---|---|---|
minicopier-master | 0.00 KB | 2009-08-00 |
ABOUT | 3.12 KB | 2009-08-00 |
LICENSE | 17.57 KB | 2009-08-00 |
Manifest.txt | 0.06 KB | 2009-08-00 |
MiniCopier.sh | 0.12 KB | 2009-08-00 |
README.md | 1.30 KB | 2009-08-00 |
build.xml | 1.02 KB | 2009-08-00 |
lib | 0.00 KB | 2009-08-00 |
PgsLookAndFeel.jar | 146.96 KB | 2009-08-00 |
src | 0.00 KB | 2009-08-00 |
img | 0.00 KB | 2009-08-00 |
alt | 0.00 KB | 2009-08-00 |
cancel.png | 0.89 KB | 2009-08-00 |
down.png | 0.93 KB | 2009-08-00 |
first.png | 0.96 KB | 2009-08-00 |
last.png | 0.95 KB | 2009-08-00 |
up.png | 0.93 KB | 2009-08-00 |
basket.png | 3.76 KB | 2009-08-00 |
delete.gif | 1.14 KB | 2009-08-00 |
down.gif | 1.00 KB | 2009-08-00 |
failed.gif | 0.92 KB | 2009-08-00 |
first.gif | 1.09 KB | 2009-08-00 |
icon.gif | 0.61 KB | 2009-08-00 |
icon.ico | 44.77 KB | 2009-08-00 |
icon.jpg | 2.95 KB | 2009-08-00 |
icon.png | 1.64 KB | 2009-08-00 |
last.gif | 1.09 KB | 2009-08-00 |
list.png | 0.32 KB | 2009-08-00 |
minicopier-logo.png | 9.32 KB | 2009-08-00 |
oldtheme | 0.00 KB | 2009-08-00 |
credits.png | 0.47 KB | 2009-08-00 |
delete.png | 0.58 KB | 2009-08-00 |
发表评论 取消回复