Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 3383a43

Browse files
committed
代码整理
1 parent 11c2a5a commit 3383a43

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/main/java/org/suren/autotest/web/framework/autoit3/AutoItCmd.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.InputStream;
2222
import java.net.URL;
2323
import java.net.URLDecoder;
24+
import java.util.Enumeration;
2425
import java.util.Properties;
2526

2627
import org.slf4j.Logger;
@@ -39,25 +40,39 @@ public class AutoItCmd
3940
private static final Logger logger = LoggerFactory.getLogger(AutoItCmd.class);
4041

4142
public static String autoitExe = null;
42-
private static final String AUTO_IT3_PATH = "autoit3.properties";
43-
private static final String FILE_CHOOSE_SCRIPT = "file_choose.au3";
43+
public static final String AUTO_IT3_PATH = "autoit3.properties";
44+
public static final String FILE_CHOOSE_SCRIPT = "file_choose.au3";
45+
46+
public static final String PRO_PATH = "path";
4447

4548
private static Properties autoItPro = new Properties();
4649

4750
private static boolean isRunning = false;
4851

4952
static
5053
{
51-
try(InputStream input = AutoItCmd.class.getClassLoader().getResourceAsStream(AUTO_IT3_PATH))
54+
try
5255
{
53-
if(input == null)
56+
Enumeration<URL> resources = AutoItCmd.class.getClassLoader().getResources(AUTO_IT3_PATH);
57+
if(resources != null)
58+
{
59+
while(resources.hasMoreElements())
60+
{
61+
URL url = resources.nextElement();
62+
63+
try(InputStream input = url.openStream())
64+
{
65+
66+
autoItPro.load(input);
67+
68+
autoitExe = autoItPro.getProperty(PRO_PATH);
69+
}
70+
}
71+
}
72+
else
5473
{
5574
throw new RuntimeException("Can not found " + AUTO_IT3_PATH + " in class path.");
5675
}
57-
58-
autoItPro.load(input);
59-
60-
autoitExe = autoItPro.getProperty("path");
6176
}
6277
catch (IOException e)
6378
{

0 commit comments

Comments
 (0)