-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProxyChanger.java
55 lines (38 loc) · 1.3 KB
/
ProxyChanger.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package proxychanger;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ProxyChanger {
private int count ;
private int counter ;
private String[] proxy ;
private String[] port ;
public ProxyChanger() {
proxy = new String[80] ;
port = new String[80] ;
counter = -1 ;
count = -1 ;
try{
FileReader f = new FileReader("proxy_port.txt") ;
BufferedReader bf = new BufferedReader(f) ;
String str ;
while( (str = bf.readLine()) != null ){
proxy[++count] = str.substring( 0, str.indexOf(" ") ).trim() ;
port[count] = str.substring( str.indexOf(" ") ).trim() ;
}
f.close();
bf.close();
}catch( IOException e ){
System.out.println( e );
}
}
public void changeProxy(){
if( counter >= count )
counter = -1 ;
System.setProperty("https.setProxy", proxy[++counter]) ;
System.setProperty("https.setPort", port[counter] ) ;
}
public String whatIsMyProxy(){
return proxy[counter] + " " + port[counter] ;
}
}