How to make ip address calculator with java netbeans
This one is a video tutorial. And here is the source code which is used in the tutorial.
For step-by-step instruction, please watch the video.
int prefix = Integer.valueOf(mask.getText());
int pos = prefix / 8; //important octet position
int rem = prefix % 8; //binary digit of importan octet
String binIpFull = "";
String subBinary = "";
String subBinaryFull = "";
String binnetidFull = "";
String binbcidFull = "";
String netmaskFull = "";
String netidFull = "";
String bcidFull = "";
//loop to generate binary mask from octet pos
for (int i = 1; i & lt; = 8; i++) {
if (i & lt; = rem) {
subBinary += "1";
} else {
subBinary += "0";
}
}
//netmask (integer version of subBinary
int netmask = Integer.parseInt(String.valueOf(subBinary), 2);
//ip octets array
int[] oct = {
Integer.valueOf(oct1.getText()),
Integer.valueOf(oct2.getText()),
Integer.valueOf(oct3.getText()),
Integer.valueOf(oct4.getText())
};
//binary of important octet
String binOct = String.format("%8s", Integer.toBinaryString(oct[pos])).replace(' ', '0');
String binNetId = "";
String binBcId = "";
for (int i = 0; i & lt; 8; i++) {
String binPointer = subBinary.substring(i, i + 1);
if (binPointer.equals("1")) {
binNetId += binOct.substring(i, i + 1);
binBcId += binOct.substring(i, i + 1);
} else {
binNetId += "0";
binBcId += "1";
}
}
//loop to generate display-ready strings
for (int i = 0; i & lt; = 3; i++) {
binIpFull += String.format("%8s", Integer.toBinaryString(oct[i])).replace(' ', '0');
if (i < pos) { = ""
subbinaryfull += "11111111"; = ""
netmaskfull = "" += "255"
binnetidfull = ""
','
0 ');="" binbcidfull="" netidfull="" bcidfull="" ="" }else="" if(i="">pos){
subBinaryFull += "00000000";
netmaskFull += "0";
binnetidFull += "00000000";
binbcidFull += "00000000";
netidFull += "0";
bcidFull += "1";
} else {
subBinaryFull += subBinary;
netmaskFull += String.valueOf(netmask);
binnetidFull += binNetId;
binbcidFull += binBcId;
netidFull += Integer.parseInt(String.valueOf(binNetId), 2);
bcidFull += Integer.parseInt(String.valueOf(binBcId), 2);
}
if (i != 3) {
subBinaryFull += ".";
netmaskFull += ".";
binnetidFull += ".";
binbcidFull += ".";
netidFull += ".";
bcidFull += ".";
binIpFull += ".";
}
}
subBinLabel.setText(subBinaryFull);
netMaskLabel.setText(netmaskFull);
netBinLabel.setText(binnetidFull);
bcBinLabel.setText(binbcidFull);
netIdLabel.setText(netidFull);
bcIdLabel.setText(bcidFull);
ipBinLabel.setText(binIpFull);
You can watch the video here:
Subscribe to:
Post Comments
(
Atom
)
Great job.... Awesome list, just starting a blog and this is going to be a massive help. Thank you!
ReplyDeleteNode JS Training in Chennai
Node JS Training
Great Article
DeleteCyber Security Projects for CSE Students
JavaScript Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. https://192-168-i-i.com
ReplyDeleteThe writer has written this blog in a very idiomatic manner.
ReplyDeletemortgage calculator
This comment has been removed by the author.
ReplyDeleteIP delivers are doled out to a host either over again after booting time or for all time through fixed design of its product or equipment. Utilizing a "static Internet Protocol address" signifies diligent design. Utilizing a "unique Internet Protocol address," then again, is doling out a PC's location from time to time. 192.168.l0.1
ReplyDeleteAmazing Article,Really useful information to all So, I hope you will share more information to be check and share here.
ReplyDeleteinplant training for biotechnology in chennai
inplant training for ece students
inplant training mechanical engineering students
inplant training certificate format for civil engineering
inplant training report ppt
inplant training report samples
inplant training letter format
inplant training report for civil engineering pdf
inplant training report for electrical engineering
Thanks for sharing such a great blog......!!!
ReplyDeletefull form
full form of nrc
nrc full form
mbbs full form
full form of rip
Grab the best AWS Training in Chennai from Infycle Technologies, the best software training institute, and Placement centre in Chennai. We also provide technical courses like Power BI, Cyber Security, Graphic Design and Animation, Block Security, Java, Oracle, Python etc. For free demo class and enquiry call 7504633633.
ReplyDeleteAlways get the most effective suite charges, exclusive resort access, comps for gaming play, and more. You’ll just must activate your on-line account utilizing your Grazie Rewards account number and PIN. By submitting this kind, would 카지노 possibly be} giving your consent for Crescent School of Gaming and Bartending to contact you relating to our applications and companies.
ReplyDelete