Posts

Showing posts from May, 2015

How to Acess All Files From Folder URL in Java

=========== ReadAllFile.java=============== /*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; /**  *  * @author anand  */ public class ReadAllFile {         public static void main (String [] args) throws IOException{                 File folder = new File("/home/anand/Anand1"); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) {   File file = listOfFiles[i];   if (file.isFile() && file.getName().endsWith(".txt")) {     String content = FileUtils.readFileToString(file);           System.out.println("Read==>"+ content );     /* do somthing with content */   } }     } } ============================================== Make Sure That you create Anand1.txt and Anand2.txt inside Anand1

How to Get Folder Name and Files Name From URL Using Java Code

=========== GetFolder.java==================== package OrderDetails; import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; import org.json.simple.JSONObject; /**  *  * @author ananddw  */ public class GetFolder {     // File directory = new File("/home/ananddw/NetBeansProjects/Welcome/web/SA-DeskConfiguration");     public static void main(String[] args) {         File currentDir = new File("/home/ananddwivedi/NetBeansProjects/Welcome/web/SA-DeskConfiguration"); // current directory         displayDirectoryContents(currentDir);     }     public static void displayDirectoryContents(File dir) {         try {             File[] files = dir.listFiles();             for (File file : files) {                 if (file.isDirectory()) {                     System.out.println("Directory Name==>:" + file.getCanonicalPath());                 

How to Read Text/Properties File From JavaScript

==== fetch.html========== <html> <body>   <div>"=="<span id="anand"/>"</div>   <script src="hi.js"></script> </body> </html> ======hi.js ============ /*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ function requestListener() {   document.querySelector("#anand").innerHTML = this.responseText; }; onload = function() {   var request = new XMLHttpRequest();   request.onload = requestListener;   request.open("GET", "content.properties", true);   request.send(); }; =========anand.properties======== Name=Anand Age= 26

How Working Directory and File seperator Works in Java

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ package Anand; import java.io.File; /**  *  * @author Ananddw  */ public class FileSep {     public static void main (String [] args){         // System.get property will give you Working Directory         String wrkDir=System.getProperty("user.dir");         //Print the working Directory         System.out.println("WrkDir===>"+wrkDir);         //Seperate file with "/" character.         System.out.println("File Seperator===>"+File.separator);         //seperate path with ":" Symbol         System.out.println("File pathSeparator===>"+File.pathSeparator);         //seperate file with "/" symbol         System.out.println("File pathSeparatorChar===>"+File.pathSeparatorChar);         //seperate file with ":&quo

how to bind you tube URL on HTML Page

Image
==========================index.html================================ <!----   To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. @author: ananddw --> <!DOCTYPE html>  <html>  <body>  <h3> Online video play from you tube using html</h3> <iframe width="560" height="315" src="https://www.youtube.com/embed/0QgmDXzv2rg" frameborder="0" allowfullscreen></iframe> </body>  </html> <style> body{         background-color: chocolate;         alignment-adjust: central;         width: auto; } iframe{ alignment-adjust: central; } </style>

How to insert Video in HTML

Image
> First you create one folder inside that you put any video from your local system but try it support mp4 format . > Create index.html file  =====================index.html========================= <!----   To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. @author: ananddw --> <!DOCTYPE html>  <html>  <body>  <video width="1000" controls>   <source src="Ariana Grande, The Weeknd - Love Me Harder.mp4" type="video/mp4">   <source src="Ariana Grande, The Weeknd - Love Me Harder.mp4" type="video/ogg">    </video> <p> <a href="http://learnjavabyanand.blogspot.in/" target="_blank">Click here on Enter on Java World</a>. </p> </body>  </html> =================================================