You are here: Home / Topics / Page / 4

Program to use File class and its methods in Java

Filed under: Java on 2023-10-25 06:51:37
//  Program to use File class and its methodsimport java.io.*;class FileDemo{   public static void main(String args[ ])    {       File f = new File("FileDemo.java");       System.out.println("File : " + f.getName() + (f.isFile() 

Program to use URLConnection class in Java

Filed under: Java on 2023-10-25 06:49:31
//  Program to use URLConnection class.import java.io.*;import java.net.*;import java.util.Date;class URLConnectionDemo{public static void main(String args[ ]) throws Exception{ int ch; URL ob = new URL("http://www.bethedeveloper.com/java/"); URLConnection uc = u.openConnection()

Program to display all parts of URL in Java

Filed under: Java on 2023-10-25 06:48:59
// Program to display all parts of URL.import java.net.*;class URLDemo{public static void main( String args[ ] ) throws Exception{ URL ob = new URL("http://www.bethedeveloper.com/java/"); System.out.println(" Protocol : " + ob.getProtocol()); System.out.println(" Host : " + ob.getHost

Program to Display host name by IP address in Java

Filed under: Java on 2023-10-25 06:48:30
// Program to Display host name by IP address.import java.net.*;class HostName{public static void main( String args[ ] ) { // byte ad[ ] = { (byte)192, (byte)168, 1, 2 };  try {  // InetAddress ip = InetAddress.getByAddress( ad );  InetAddress ip = InetAddress.getB

Program to create Menu in AWT in Java

Filed under: Java on 2023-10-25 06:47:10
//  Program to create Menu in AWT.import java.awt.*;import java.applet.*;import java.awt.event.*;class MyMenu extends Frame implements ActionListener{String str="";CheckboxMenuItem cmiBold , cmiItalic;MenuItem miNew , miOpen , miSave, miCut, miCopy, miPaste, miRed, miGreen, miBlue;MyMenu(){&nbs