问题
Is it possible to disconnect from one wi-fi network and connect to another network programatically using java?
My java application makes request to twitter using twitter4j. I can make only 350 requests per hour from a particular IP address. Now I'm sleeping for an hour before continuing my requests. But I have two Wi-Fi networks to connect to.
So when the limit exceeds and I get an exception, if I can switch between the networks, I can double the amount of work done. Is it possible in java?
回答1:
It's only possible in java because java can call native code. You would need to implement this with native code in C or C++.
回答2:
You could execute from your Java program an external program that would disconnect and reconnect (if you get an IP via DHCP).
Doesn't seem like the solution lies in the program, though. More in the way it's being used... or what it's being used (or shouldn't be used) for.
来源:https://stackoverflow.com/questions/11020965/how-to-switch-between-networks-from-a-java-application