Posts

Showing posts from 2015

Online Book Store Website Using Java

Image
=============================================== Login.html:- ================================================ <html>     <title>|| Login Page ||</title>     <body class="bod">         <form action='login.action'  method="post">             <table align='center'>                 <tr><td colspan='2' align='center'>                         <br></br>                         <h2 style="color: black; font-size: 30px; padding-top: 1%;" class="Head">User Login</h2></td></tr>                 <tr>                     <td><h2>UserName</h2></td>                     <td><input type='text' name='UserName' placeholder="UserName" autocomplete="off" required=""/></td></tr>                 <tr>                     <td><h

How to Create PDF File Using Java Code

package com.anand; import com.lowagie.text.Document; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.util.Date; public class GeneratePDF {     public static void main(String[] args) {         try {             OutputStream file = new FileOutputStream(new File("/home/ananddw/test.pdf"));             Document document = new Document();             PdfWriter.getInstance(document, file);             document.open();             document.add(new Paragraph("welcome Anand in the World of PDF "));                        document.close();             file.close();         } catch (Exception e) {             e.printStackTrace();         }     } } =============================================== Attach Some Require Jar else you will get error  Thanks  Anand Dwivedi

How to append Same File name With Date Append in Java?

Please Find Code Below : ==================Append.java======================= import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.Date; /**  *  * @author ananddw  */ public class Append {     public static void main(String[] args) throws IOException {         /*          Date date = new Date();         File file1 = new File("/home/ananddw/Anand.json");         String file2 = file1.getParent().toString();         System.out.println("file 2 call ===>" + file2);         boolean b = false;         if (!(file1.exists())) {             b = file1.createNewFile();         }         if (b) {             System.out.println("Empty File successfully created");         } else {             String fileContent = "";               String filename = file1.toString() + date;             try {                 File f =

File Monitoring Using Java API

Image
======================WatchDog.java====================================== package net.codejava.io; import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; import java.nio.file.WatchService; /**  *   * @author anand  *  */ public class WatchDog {     public static void main(String[] args) {         try {             WatchService watcher = FileSystems.getDefault().newWatchService();             Path dir = Paths.get("F:\\video s\\south indian");             dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);                           System.out.println("Registered  dir:===>" + dir.getFileName());          

How To Upload File Using Struts

Image
===============================index.jsp================================= <%--      Document   : index     Created on : Jun 17, 2015, 8:32:59 PM     Author     : Anand --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>File Upload</title> </head> <body>       <center>    <form action="upload" method="post" enctype="multipart/form-data">       <label for="myFile">Upload your file</label>       <input type="file" name="myFile" />       <input type="submit" value="Upload" onclick="run()"/>    </f