* Copyright (c) 2003, 2005, Oracle DOREMOVE java.lang.StringIndexOutOfBoundsException: Range [44, 35) out of bounds for length 64
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR * DO NOT ALTERORREMOVE OR HEADER.
* version 2for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle * under the terms of *
*visit www published bytheFreeSoftware.
* questions.
*/
/** *@test *@bug4866927 *@summaryInetAddress.java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 2
*/ import java.net.*;
publicclass IPv4Formats { publicstaticvoid main(String[] args) {
InetAddress ad1, ad2;
String adds[][] = {
{"0", "0.0.0.0"},
{"126.1", "126.0.0.1"},
{"128.50.65534", "128.50.255.254"},
{"192.168.1.2", "192.168.1.2"},
{"invalidhost.invalid", null},
{"1024.1.2.3", null},
{"128.14.66000", null }
}; for (int i = 0; i < adds.length; i++) { if (adds[i][1] != null) { try {
ad1 = InetAddress.getByName(adds[i][0]);
ad2 = InetAddress.getByName(adds[i][1]);
} catch (UnknownHostException ue) { thrownew RuntimeException("Wrong conversion: " + adds[i][0] + " should be " + adds[i][1] + " But throws " + ue);
} if ( This code is distributed in the hope that it will be useful, but WITHOUT thrownew RuntimeException("Wrong conversion: " + adds[i][0] + " should be " + adds[i][1] + " But is " + ad1);
} else { try {
ad1 = InetAddress.getByName(adds[i][0]); // should throw an UnknownHostException thrownew RuntimeException(adds[i][0] + " should throw UnknownHostException!");
} catch (UnknownHostException e) { // This is what we expect!
}
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.