Use Integer.parseInt(String) to get a primitive int.

This commit is contained in:
akwizgran
2013-04-25 05:07:26 +01:00
parent 178c486a4a
commit 1e5e78cc44
5 changed files with 5 additions and 5 deletions

View File

@@ -84,7 +84,7 @@ implements OnEditorActionListener, OnClickListener {
String remoteCodeString = codeEntry.getText().toString();
int remoteCode;
try {
remoteCode = Integer.valueOf(remoteCodeString);
remoteCode = Integer.parseInt(remoteCodeString);
} catch(NumberFormatException e) {
return false;
}

View File

@@ -73,7 +73,7 @@ class LanTcpPlugin extends TcpPlugin {
!StringUtils.isNullOrEmpty(portString)) {
try {
addr = InetAddress.getByName(addrString);
int port = Integer.valueOf(portString);
int port = Integer.parseInt(portString);
addrs.add(new InetSocketAddress(addr, port));
addrs.add(new InetSocketAddress(addr, 0));
} catch(NumberFormatException e) {

View File

@@ -191,7 +191,7 @@ abstract class TcpPlugin implements DuplexPlugin {
if(StringUtils.isNullOrEmpty(portString)) return null;
try {
InetAddress addr = InetAddress.getByName(addrString);
int port = Integer.valueOf(portString);
int port = Integer.parseInt(portString);
return new InetSocketAddress(addr, port);
} catch(NumberFormatException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -64,7 +64,7 @@ class WanTcpPlugin extends TcpPlugin {
!StringUtils.isNullOrEmpty(portString)) {
try {
addr = InetAddress.getByName(addrString);
port = Integer.valueOf(portString);
port = Integer.parseInt(portString);
addrs.add(new InetSocketAddress(addr, port));
addrs.add(new InetSocketAddress(addr, 0));
} catch(NumberFormatException e) {

View File

@@ -45,7 +45,7 @@ public class LanTcpPluginTest extends BriarTestCase {
assertEquals("127.0.0.1", host);
String portString = callback.local.get("port");
assertNotNull(portString);
int port = Integer.valueOf(portString);
int port = Integer.parseInt(portString);
assertTrue(port > 0 && port < 65536);
// The plugin should be listening on the port
InetSocketAddress addr = new InetSocketAddress(host, port);