change charactor encoding to UTF-8

dev
yuqing 2017-04-17 10:41:25 +08:00
parent 10811b3f41
commit 3fadb8ad41
6 changed files with 120 additions and 146 deletions

View File

@ -14,14 +14,14 @@ run the FastDFS Java Client test:
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.TestClient <config_filename> <upload_filename> java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.TestClient <config_filename> <upload_filename>
eg.: eg.:
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.TestClient fdfs_client.conf c:\windows\system32\notepad.exe java -cp fastdfs_client_v1.25.jar org.csource.fastdfs.test.TestClient fdfs_client.conf c:\windows\system32\notepad.exe
or: or:
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.TestClient fdfs_client.conf /usr/include/stdlib.h java -cp fastdfs_client_v1.25.jar org.csource.fastdfs.test.TestClient fdfs_client.conf /usr/include/stdlib.h
run the FastDFS monitor: run the FastDFS monitor:
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.Monitor <config_filename> java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.Monitor <config_filename>
eg.: eg.:
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.Monitor fdfs_client.conf java -cp fastdfs_client_v1.25.jar org.csource.fastdfs.test.Monitor fdfs_client.conf

View File

@ -26,7 +26,7 @@
destdir="${fastdfs_client.bin_dir}" destdir="${fastdfs_client.bin_dir}"
includes="org/**/*.java" includes="org/**/*.java"
debug="on" debug="on"
encoding="ISO8859-1" encoding="UTF-8"
failonerror="true"/> failonerror="true"/>
</target> </target>

View File

@ -1,9 +1,9 @@
connect_timeout = 2 connect_timeout = 2
network_timeout = 30 network_timeout = 30
charset = ISO8859-1 charset = UTF-8
http.tracker_http_port = 8080 http.tracker_http_port = 8080
http.anti_steal_token = no http.anti_steal_token = no
http.secret_key = FastDFS1234567890 http.secret_key = FastDFS1234567890
tracker_server = 192.168.0.116:22122 tracker_server = 10.0.11.243:22122
tracker_server = 192.168.0.119:22122 tracker_server = 10.0.11.244:22122

View File

@ -461,7 +461,7 @@ public class Base64
try try
{ {
Base64 b64 = new Base64(); Base64 b64 = new Base64();
String str = "agfrtu喀et什1234假大erty空234发喀2344什的"; String str = "agfrtu¿¦etʲ1234¼Ù´óerty¿Õ234·¢¿¦2344ʲµÄ";
String str64 = ""; String str64 = "";
//encode //encode

View File

@ -127,91 +127,56 @@ public class IniFileReader
} }
private void loadFromFile(String conf_filename) throws FileNotFoundException, IOException private void loadFromFile(String conf_filename) throws FileNotFoundException, IOException
{ {
//修改人 孟鹏飞,问题说明 使用中发现原来客户端打jar包后在另一个项目中引用另一个项目打jar包后运行时找不到客户端配置文件 ,能不能把我名字加上,以后好找工作 //修改人 孟鹏飞,问题说明 使用中发现原来客户端打jar包后在另一个项目中引用另一个项目打jar包后运行时找不到客户端配置文件 ,能不能把我名字加上,以后好找工作
// FileReader fReader; String name;
// BufferedReader buffReader; String value;
// String line; Object obj;
// String[] parts; ArrayList valueList;
String name; InputStream is=null;
String value; this.paramTable = new Hashtable();
Object obj;
ArrayList valueList;
InputStream is=null;
// fReader = new FileReader(conf_filename);
// buffReader = new BufferedReader(fReader);
this.paramTable = new Hashtable();
try try
{ {
// while ((line=buffReader.readLine()) != null) Properties props;
// { try {
// line = line.trim(); is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename);
// if (line.length() == 0 || line.charAt(0) == '#') props = new Properties();
// { props.load(is);
// continue; } catch (Exception ex) {
// } is = new FileInputStream(conf_filename);
// props = new Properties();
// parts = line.split("=", 2); props.load(is);
// if (parts.length != 2) }
// { Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
// continue; while (it.hasNext()) {
// } Map.Entry<Object, Object> entry = it.next();
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename); name= entry.getKey().toString();
// System.out.println(conf_filename+"========================================"); value = entry.getValue().toString();
Properties props = new Properties(); obj = this.paramTable.get(name);
props.load(is); if (obj == null)
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator(); {
while (it.hasNext()) { this.paramTable.put(name, value);
Map.Entry<Object, Object> entry = it.next(); }
name= entry.getKey().toString(); else if (obj instanceof String)
value = entry.getValue().toString(); {
// System.out.println(name+"======================================"); valueList = new ArrayList();
obj = this.paramTable.get(name); valueList.add(obj);
if (obj == null) valueList.add(value);
{ this.paramTable.put(name, valueList);
this.paramTable.put(name, value); }
} else
else if (obj instanceof String) {
{ valueList = (ArrayList)obj;
valueList = new ArrayList(); valueList.add(value);
valueList.add(obj); }
valueList.add(value); }
this.paramTable.put(name, valueList); }
} finally
else {
{ if (is != null) {
valueList = (ArrayList)obj; is.close();
valueList.add(value); }
} }
} }
// name = parts[0].trim();
// value = parts[1].trim();
// obj = this.paramTable.get(name);
// if (obj == null)
// {
// this.paramTable.put(name, value);
// }
// else if (obj instanceof String)
// {
// valueList = new ArrayList();
// valueList.add(obj);
// valueList.add(value);
// this.paramTable.put(name, valueList);
// }
// else
// {
// valueList = (ArrayList)obj;
// valueList.add(value);
// }
// }
}
finally
{
if (is!=null)
is.close();
// fReader.close();
}
}
} }

View File

@ -11,13 +11,13 @@ public class Test1
{ {
public static void main(String args[]) public static void main(String args[])
{ {
try try
{ {
ClientGlobal.init("fdfs_client.conf"); ClientGlobal.init("fdfs_client.conf");
System.out.println("network_timeout=" + ClientGlobal.g_network_timeout + "ms"); System.out.println("network_timeout=" + ClientGlobal.g_network_timeout + "ms");
System.out.println("charset=" + ClientGlobal.g_charset); System.out.println("charset=" + ClientGlobal.g_charset);
TrackerGroup tg = new TrackerGroup(new InetSocketAddress[]{new InetSocketAddress("192.168.0.196", 22122)}); TrackerGroup tg = new TrackerGroup(new InetSocketAddress[]{new InetSocketAddress("10.0.11.243", 22122)});
TrackerClient tc = new TrackerClient(tg); TrackerClient tc = new TrackerClient(tg);
TrackerServer ts = tc.getConnection(); TrackerServer ts = tc.getConnection();
@ -36,8 +36,18 @@ public class Test1
StorageClient1 sc1 = new StorageClient1(ts, ss); StorageClient1 sc1 = new StorageClient1(ts, ss);
NameValuePair[] meta_list = null; //new NameValuePair[0]; NameValuePair[] meta_list = null; //new NameValuePair[0];
String item = "c:/windows/system32/notepad.exe"; String item;
String fileid = sc1.upload_file1(item, "exe", meta_list); //此行异常 String fileid;
if (System.getProperty("os.name").equalsIgnoreCase("windows"))
{
item = "c:/windows/system32/notepad.exe";
fileid = sc1.upload_file1(item, "exe", meta_list);
}
else
{
item = "/etc/hosts";
fileid = sc1.upload_file1(item, "", meta_list);
}
System.out.println("Upload local file "+item+" ok, fileid="+fileid); System.out.println("Upload local file "+item+" ok, fileid="+fileid);
} }
@ -45,6 +55,5 @@ public class Test1
{ {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
} }