Skip to content

Commit 3fadb8a

Browse files
author
yuqing
committed
change charactor encoding to UTF-8
1 parent 10811b3 commit 3fadb8a

File tree

6 files changed

+120
-146
lines changed

6 files changed

+120
-146
lines changed

src/README

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ run the FastDFS Java Client test:
1414
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.TestClient <config_filename> <upload_filename>
1515

1616
eg.:
17-
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.TestClient fdfs_client.conf c:\windows\system32\notepad.exe
17+
java -cp fastdfs_client_v1.25.jar org.csource.fastdfs.test.TestClient fdfs_client.conf c:\windows\system32\notepad.exe
1818

1919
or:
20-
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.TestClient fdfs_client.conf /usr/include/stdlib.h
20+
java -cp fastdfs_client_v1.25.jar org.csource.fastdfs.test.TestClient fdfs_client.conf /usr/include/stdlib.h
2121

2222

2323
run the FastDFS monitor:
2424
java -cp <fastdfs_client_jar_filename> org.csource.fastdfs.test.Monitor <config_filename>
2525

2626
eg.:
27-
java -cp fastdfs_client_v1.22.jar org.csource.fastdfs.test.Monitor fdfs_client.conf
27+
java -cp fastdfs_client_v1.25.jar org.csource.fastdfs.test.Monitor fdfs_client.conf

src/build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
destdir="${fastdfs_client.bin_dir}"
2727
includes="org/**/*.java"
2828
debug="on"
29-
encoding="ISO8859-1"
29+
encoding="UTF-8"
3030
failonerror="true"/>
3131
</target>
3232

@@ -52,4 +52,4 @@
5252
<target name="core" depends="compile"/>
5353

5454
</project>
55-
55+

src/fdfs_client.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
connect_timeout = 2
22
network_timeout = 30
3-
charset = ISO8859-1
3+
charset = UTF-8
44
http.tracker_http_port = 8080
55
http.anti_steal_token = no
66
http.secret_key = FastDFS1234567890
77

8-
tracker_server = 192.168.0.116:22122
9-
tracker_server = 192.168.0.119:22122
8+
tracker_server = 10.0.11.243:22122
9+
tracker_server = 10.0.11.244:22122

src/org/csource/common/Base64.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ public static void main(String[] args)
461461
try
462462
{
463463
Base64 b64 = new Base64();
464-
String str = "agfrtu¿¦etʲ1234¼Ù´óerty¿Õ234·¢¿¦2344ʲµÄ";
464+
String str = "agfrtu¿¦etʲ1234¼Ù´óerty¿Õ234·¢¿¦2344ʲµÄ";
465465
String str64 = "";
466466

467467
//encode

src/org/csource/common/IniFileReader.java

Lines changed: 52 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -127,91 +127,56 @@ public String[] getValues(String name)
127127
}
128128

129129
private void loadFromFile(String conf_filename) throws FileNotFoundException, IOException
130-
{
131-
//修改人 孟鹏飞,问题说明 使用中发现原来客户端打jar包后,在另一个项目中引用,另一个项目打jar包后运行时找不到客户端配置文件 ,能不能把我名字加上,以后好找工作
132-
// FileReader fReader;
133-
// BufferedReader buffReader;
134-
// String line;
135-
// String[] parts;
136-
String name;
137-
String value;
138-
Object obj;
139-
ArrayList valueList;
140-
InputStream is=null;
141-
// fReader = new FileReader(conf_filename);
142-
// buffReader = new BufferedReader(fReader);
143-
this.paramTable = new Hashtable();
144-
145-
try
146-
{
147-
// while ((line=buffReader.readLine()) != null)
148-
// {
149-
// line = line.trim();
150-
// if (line.length() == 0 || line.charAt(0) == '#')
151-
// {
152-
// continue;
153-
// }
154-
//
155-
// parts = line.split("=", 2);
156-
// if (parts.length != 2)
157-
// {
158-
// continue;
159-
// }
160-
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename);
161-
// System.out.println(conf_filename+"========================================");
162-
Properties props = new Properties();
163-
props.load(is);
164-
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
165-
while (it.hasNext()) {
166-
Map.Entry<Object, Object> entry = it.next();
167-
name= entry.getKey().toString();
168-
value = entry.getValue().toString();
169-
// System.out.println(name+"======================================");
170-
obj = this.paramTable.get(name);
171-
if (obj == null)
172-
{
173-
this.paramTable.put(name, value);
174-
}
175-
else if (obj instanceof String)
176-
{
177-
valueList = new ArrayList();
178-
valueList.add(obj);
179-
valueList.add(value);
180-
this.paramTable.put(name, valueList);
181-
}
182-
else
183-
{
184-
valueList = (ArrayList)obj;
185-
valueList.add(value);
186-
}
187-
}
188-
// name = parts[0].trim();
189-
// value = parts[1].trim();
190-
191-
// obj = this.paramTable.get(name);
192-
// if (obj == null)
193-
// {
194-
// this.paramTable.put(name, value);
195-
// }
196-
// else if (obj instanceof String)
197-
// {
198-
// valueList = new ArrayList();
199-
// valueList.add(obj);
200-
// valueList.add(value);
201-
// this.paramTable.put(name, valueList);
202-
// }
203-
// else
204-
// {
205-
// valueList = (ArrayList)obj;
206-
// valueList.add(value);
207-
// }
208-
// }
209-
}
210-
finally
211-
{
212-
if (is!=null)
213-
is.close();
214-
// fReader.close();
215-
}
216-
}
130+
{
131+
//修改人 孟鹏飞,问题说明 使用中发现原来客户端打jar包后,在另一个项目中引用,另一个项目打jar包后运行时找不到客户端配置文件 ,能不能把我名字加上,以后好找工作
132+
String name;
133+
String value;
134+
Object obj;
135+
ArrayList valueList;
136+
InputStream is=null;
137+
this.paramTable = new Hashtable();
138+
139+
try
140+
{
141+
Properties props;
142+
try {
143+
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename);
144+
props = new Properties();
145+
props.load(is);
146+
} catch (Exception ex) {
147+
is = new FileInputStream(conf_filename);
148+
props = new Properties();
149+
props.load(is);
150+
}
151+
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
152+
while (it.hasNext()) {
153+
Map.Entry<Object, Object> entry = it.next();
154+
name= entry.getKey().toString();
155+
value = entry.getValue().toString();
156+
obj = this.paramTable.get(name);
157+
if (obj == null)
158+
{
159+
this.paramTable.put(name, value);
160+
}
161+
else if (obj instanceof String)
162+
{
163+
valueList = new ArrayList();
164+
valueList.add(obj);
165+
valueList.add(value);
166+
this.paramTable.put(name, valueList);
167+
}
168+
else
169+
{
170+
valueList = (ArrayList)obj;
171+
valueList.add(value);
172+
}
173+
}
174+
}
175+
finally
176+
{
177+
if (is != null) {
178+
is.close();
179+
}
180+
}
181+
}
217182
}
Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,59 @@
1-
2-
package org.csource.fastdfs.test;
3-
4-
import java.io.*;
5-
import java.net.*;
6-
import java.util.*;
7-
import org.csource.common.*;
8-
import org.csource.fastdfs.*;
9-
10-
public class Test1
11-
{
12-
public static void main(String args[])
13-
{
14-
try
15-
{
16-
ClientGlobal.init("fdfs_client.conf");
17-
System.out.println("network_timeout=" + ClientGlobal.g_network_timeout + "ms");
18-
System.out.println("charset=" + ClientGlobal.g_charset);
19-
20-
TrackerGroup tg = new TrackerGroup(new InetSocketAddress[]{new InetSocketAddress("192.168.0.196", 22122)});
21-
TrackerClient tc = new TrackerClient(tg);
22-
23-
TrackerServer ts = tc.getConnection();
24-
if (ts == null)
25-
{
26-
System.out.println("getConnection return null");
27-
return;
28-
}
29-
30-
StorageServer ss = tc.getStoreStorage(ts);
31-
if (ss == null)
32-
{
33-
System.out.println("getStoreStorage return null");
34-
}
35-
36-
StorageClient1 sc1 = new StorageClient1(ts, ss);
37-
38-
NameValuePair[] meta_list = null; //new NameValuePair[0];
39-
String item = "c:/windows/system32/notepad.exe";
40-
String fileid = sc1.upload_file1(item, "exe", meta_list); //´ËÐÐÒì³£
41-
42-
System.out.println("Upload local file "+item+" ok, fileid="+fileid);
43-
}
44-
catch(Exception ex)
45-
{
46-
ex.printStackTrace();
47-
}
48-
49-
}
50-
}
1+
2+
package org.csource.fastdfs.test;
3+
4+
import java.io.*;
5+
import java.net.*;
6+
import java.util.*;
7+
import org.csource.common.*;
8+
import org.csource.fastdfs.*;
9+
10+
public class Test1
11+
{
12+
public static void main(String args[])
13+
{
14+
try
15+
{
16+
ClientGlobal.init("fdfs_client.conf");
17+
System.out.println("network_timeout=" + ClientGlobal.g_network_timeout + "ms");
18+
System.out.println("charset=" + ClientGlobal.g_charset);
19+
20+
TrackerGroup tg = new TrackerGroup(new InetSocketAddress[]{new InetSocketAddress("10.0.11.243", 22122)});
21+
TrackerClient tc = new TrackerClient(tg);
22+
23+
TrackerServer ts = tc.getConnection();
24+
if (ts == null)
25+
{
26+
System.out.println("getConnection return null");
27+
return;
28+
}
29+
30+
StorageServer ss = tc.getStoreStorage(ts);
31+
if (ss == null)
32+
{
33+
System.out.println("getStoreStorage return null");
34+
}
35+
36+
StorageClient1 sc1 = new StorageClient1(ts, ss);
37+
38+
NameValuePair[] meta_list = null; //new NameValuePair[0];
39+
String item;
40+
String fileid;
41+
if (System.getProperty("os.name").equalsIgnoreCase("windows"))
42+
{
43+
item = "c:/windows/system32/notepad.exe";
44+
fileid = sc1.upload_file1(item, "exe", meta_list);
45+
}
46+
else
47+
{
48+
item = "/etc/hosts";
49+
fileid = sc1.upload_file1(item, "", meta_list);
50+
}
51+
52+
System.out.println("Upload local file "+item+" ok, fileid="+fileid);
53+
}
54+
catch(Exception ex)
55+
{
56+
ex.printStackTrace();
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)