Skip to main content

Posts

Showing posts from July, 2017

java program which read data from file and show their details

package june29; import java.io.FileInputStream; import java.util.Scanner; public class input_from_file { public static void main(String[] args) throws Exception {  Scanner sc = new Scanner(System.in);  System.out.print("enter a file name with full path: ");  String filePath=sc.nextLine();  FileInputStream fis=new FileInputStream(filePath);  int bytes=fis.available();  int alphaUpper=0, alphaLower=0, numeric=0, space=0, line=1;  System.out.println("showing file data ->");  while(true)  {   int var=fis.read();     if(var==-1) {    break;   }   if(var>='A' && var<='Z') {    alphaUpper++;   }   else if(var>='a' && var<='z') {    alphaLower++;   }   else if(var>='0' && var<='9') {    numeric++; ...

java program which show application of string class

package june22; import java.util.Scanner; public class stringcheck_passwardusername { public static void main(String[] args) { System.out.println("Please enter your useername\t:\t"); Scanner sc = new Scanner ( System.in); String a=sc.nextLine(); System.out.println("enter your passward\t:\t"); String b=sc.nextLine(); if((a.equalsIgnoreCase( "ADMIN"))&&(b.equals("A@b123" ))){ System.out.println("welcome ADMIN"); } else System.out.println("invalid username or passward"); } }

JAVA program for finding the ip address of required host name

package june29; import java.net.InetAddress; public class testInetaddress { public static void main(String[] args) throws Exception { InetAddress in = InetAddress.getByName( "facebook.com"); String ip= in.getHostAddress(); String host=in.getHostName(); System.out.println(" host name: "+host); System.out.println("ip address : "+ip); } }