change charactor encoding to UTF-8
parent
10811b3f41
commit
3fadb8ad41
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
@ -52,4 +52,4 @@
|
||||||
<target name="core" depends="compile"/>
|
<target name="core" depends="compile"/>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
try
|
||||||
InputStream is=null;
|
{
|
||||||
// fReader = new FileReader(conf_filename);
|
Properties props;
|
||||||
// buffReader = new BufferedReader(fReader);
|
try {
|
||||||
this.paramTable = new Hashtable();
|
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename);
|
||||||
|
props = new Properties();
|
||||||
try
|
props.load(is);
|
||||||
{
|
} catch (Exception ex) {
|
||||||
// while ((line=buffReader.readLine()) != null)
|
is = new FileInputStream(conf_filename);
|
||||||
// {
|
props = new Properties();
|
||||||
// line = line.trim();
|
props.load(is);
|
||||||
// if (line.length() == 0 || line.charAt(0) == '#')
|
}
|
||||||
// {
|
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
|
||||||
// continue;
|
while (it.hasNext()) {
|
||||||
// }
|
Map.Entry<Object, Object> entry = it.next();
|
||||||
//
|
name= entry.getKey().toString();
|
||||||
// parts = line.split("=", 2);
|
value = entry.getValue().toString();
|
||||||
// if (parts.length != 2)
|
obj = this.paramTable.get(name);
|
||||||
// {
|
if (obj == null)
|
||||||
// continue;
|
{
|
||||||
// }
|
this.paramTable.put(name, value);
|
||||||
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename);
|
}
|
||||||
// System.out.println(conf_filename+"========================================");
|
else if (obj instanceof String)
|
||||||
Properties props = new Properties();
|
{
|
||||||
props.load(is);
|
valueList = new ArrayList();
|
||||||
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
|
valueList.add(obj);
|
||||||
while (it.hasNext()) {
|
valueList.add(value);
|
||||||
Map.Entry<Object, Object> entry = it.next();
|
this.paramTable.put(name, valueList);
|
||||||
name= entry.getKey().toString();
|
}
|
||||||
value = entry.getValue().toString();
|
else
|
||||||
// System.out.println(name+"======================================");
|
{
|
||||||
obj = this.paramTable.get(name);
|
valueList = (ArrayList)obj;
|
||||||
if (obj == null)
|
valueList.add(value);
|
||||||
{
|
}
|
||||||
this.paramTable.put(name, value);
|
}
|
||||||
}
|
}
|
||||||
else if (obj instanceof String)
|
finally
|
||||||
{
|
{
|
||||||
valueList = new ArrayList();
|
if (is != null) {
|
||||||
valueList.add(obj);
|
is.close();
|
||||||
valueList.add(value);
|
}
|
||||||
this.paramTable.put(name, valueList);
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
valueList = (ArrayList)obj;
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,59 @@
|
||||||
|
|
||||||
package org.csource.fastdfs.test;
|
package org.csource.fastdfs.test;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.csource.common.*;
|
import org.csource.common.*;
|
||||||
import org.csource.fastdfs.*;
|
import org.csource.fastdfs.*;
|
||||||
|
|
||||||
public class Test1
|
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();
|
||||||
if (ts == null)
|
if (ts == null)
|
||||||
{
|
{
|
||||||
System.out.println("getConnection return null");
|
System.out.println("getConnection return null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageServer ss = tc.getStoreStorage(ts);
|
StorageServer ss = tc.getStoreStorage(ts);
|
||||||
if (ss == null)
|
if (ss == null)
|
||||||
{
|
{
|
||||||
System.out.println("getStoreStorage return null");
|
System.out.println("getStoreStorage return null");
|
||||||
}
|
}
|
||||||
|
|
||||||
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"))
|
||||||
System.out.println("Upload local file "+item+" ok, fileid="+fileid);
|
{
|
||||||
}
|
item = "c:/windows/system32/notepad.exe";
|
||||||
catch(Exception ex)
|
fileid = sc1.upload_file1(item, "exe", meta_list);
|
||||||
{
|
}
|
||||||
ex.printStackTrace();
|
else
|
||||||
}
|
{
|
||||||
|
item = "/etc/hosts";
|
||||||
}
|
fileid = sc1.upload_file1(item, "", meta_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Upload local file "+item+" ok, fileid="+fileid);
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue