Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
common
Commits
c84f699d
Commit
c84f699d
authored
Apr 20, 2020
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
c0b08c84
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
HttpUtil.java
src/main/java/com/egolm/common/HttpUtil.java
+5
-4
StringUtil.java
src/main/java/com/egolm/common/StringUtil.java
+2
-1
No files found.
src/main/java/com/egolm/common/HttpUtil.java
View file @
c84f699d
...
...
@@ -13,6 +13,7 @@ import java.net.URLEncoder;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -104,8 +105,8 @@ public class HttpUtil {
System
.
out
.
println
(
requestUrl
);
connection
=
createConnection
(
requestUrl
,
proxy
);
connection
.
setRequestMethod
(
"GET"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
charset
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
//
connection.setRequestProperty("Accept-Charset", charset);
//
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
if
(
header
!=
null
)
{
for
(
String
key
:
header
.
keySet
())
{
connection
.
setRequestProperty
(
key
,
header
.
get
(
key
));
...
...
@@ -176,6 +177,7 @@ public class HttpUtil {
try
{
bytes
=
FileUtil
.
streamToBytes
(
connection
.
getInputStream
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
bytes
=
FileUtil
.
streamToBytes
(
connection
.
getErrorStream
());
}
Map
<
String
,
List
<
String
>>
responseHeaders
=
connection
.
getHeaderFields
();
...
...
@@ -257,8 +259,7 @@ public class HttpUtil {
for
(
Object
key
:
parameters
.
keySet
())
{
Object
val
=
parameters
.
get
(
key
);
String
sKey
=
String
.
valueOf
(
key
);
Object
[]
sVals
=
(
val
==
null
?
null
:
(
val
instanceof
Object
[]
?
(
Object
[])
val
:
new
Object
[]
{
val
}));
Object
[]
sVals
=
(
val
==
null
?
null
:
(
val
instanceof
Object
[]
?
(
Object
[])
val
:
(
val
instanceof
Collection
<?>
?
((
Collection
<?>)
val
).
toArray
()
:
new
Object
[]
{
val
})));
if
(
sVals
!=
null
&&
sVals
.
length
>
0
)
{
for
(
Object
sVal
:
sVals
)
{
if
(
StringUtil
.
isNotEmpty
(
sVal
))
{
...
...
src/main/java/com/egolm/common/StringUtil.java
View file @
c84f699d
...
...
@@ -1001,7 +1001,8 @@ public class StringUtil {
public
static
String
[]
searchNumber
(
String
string
)
{
List
<
String
>
numbers
=
new
ArrayList
<
String
>();
Pattern
pattern
=
Pattern
.
compile
(
"[\\d]+(\\.?[\\d]+)?"
);
String
regexText
=
"\\d+(\\.\\d+)?"
;
Pattern
pattern
=
Pattern
.
compile
(
regexText
);
Matcher
matcher
=
pattern
.
matcher
(
string
);
while
(
matcher
.
find
())
{
numbers
.
add
(
matcher
.
group
(
0
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment