Java File Operation Example #Java Short Notes

Code that helped me to create http://add.justEtc.net – the Bangladesh section based on the the web-site http://winnipeg.justEtc.net

package hello;import javax.swing.JOptionPane;import java.util.ArrayList;import java.util.Iterator;import java.io.*;/** * Created by IntelliJ IDEA. * User: Sayed Ahmed * Date: May 30, 2008 * Time: 9:45:08 PM * To change this template use File | Settings | File Templates. *//**Class containing major methods - operation methods*/class Process{    private FileReader src = null; //source folder    private FileWriter dest = null; //destination folder    private ArrayList cityList = new ArrayList(); //arraylist to contain 	//the names of all cities    private String cityFileName; //reference to the file containing all city names    private String folderToCopy; //path to the folder to be copied    private String destination; // path  to the folder where the copy will be kept    /**     * Constructor     */    Process(){//JOptionPane.showInputDialog(null,"City File Name");        cityFileName = "C:test_developmentjavaresourcescityList.txt";  //JOptionPane.showInputDialog(null,"Folder to Copy");        folderToCopy = "C:test_developmentjavahellosrcresourcessource	Winnipeg";  //JOptionPane.showInputDialog(null,"Destination Path");         destination = "C:test_developmentjavahellosrcresources	destination";                 //load city list from the file to an arraylist        copyCityList(cityFileName);        //to create a file with links to all the cities of Bangladesh        //createFile();        //copy a folder (winnipeg) and rename it to all the city names of 	//Bangladesh -- one by one        Iterator it = cityList.iterator();        while(it.hasNext()){            copyDirectory((String) it.next());        }    }    /**     * load city list into an ArrayList     */    private void copyCityList(String cityFileName){        String city = "";        try {            BufferedReader bfCity = new BufferedReader(new FileReader(cityFileName));            while(null != (city = bfCity.readLine())){                cityList.add(city);            }        } catch (IOException e) {            e.printStackTrace();  //To change body of catch statement use File 				//| Settings | File Templates.        } finally {        }    }    /**     * copy a folder , name the folder as the city name     */    private void copyDirectory(String city){        try {            copyDirectory(new File(folderToCopy), new File(destination+"/"+city), 		city);        }catch (IOException e){            e.printStackTrace();        }    }    /**     * Copies all files under srcDir to dstDir.     * If dstDir does not exist, it will be created.     * @param srcDir - folder to copy     * @param dstDir - where to keep     * @param city  - new folder name     * @throws IOException     */    public void copyDirectory(File srcDir, File dstDir, String city) throws 	IOException {        //if srcDirectory is a directory , create the directory        if (srcDir.isDirectory()) {            if (!dstDir.exists()) {                dstDir.mkdir();            }            //if srcDir has child directories , create child directories - 		Recursively            String[] children = srcDir.list();            for (int i=0; i<children .length; i++) {                copyDirectory(new File(srcDir, children[i]),                                     new File(dstDir, children[i]),city);            }        } else {            //srcDir is a file, so copy it to the new location            copyFile(srcDir, dstDir, city);        }    }    /**     * Copy a file     * @param src - source file     * @param dst - destination file     * @param city - city under consideration     */    private void copyFile(File src, File dst, String city) {        InputStream in;        OutputStream out;        try {            in = new FileInputStream(src);            out = new FileOutputStream(dst);            BufferedReader myInput = new BufferedReader   (new InputStreamReader(in));            PrintWriter myOutput = new PrintWriter(dst);            String thisLine = "";            //replace old city name with the new city name            while ((thisLine = myInput.readLine()) != null) {              if (thisLine.contains("Winnipeg")){                  thisLine=thisLine.replaceAll("Winnipeg", city);                  thisLine=thisLine.replaceAll("Manitoba,", "");                  thisLine=thisLine.replaceAll("Canada", "Bangladesh");              }              myOutput.write(thisLine);              myOutput.write("n");            }            myOutput.flush();            in.close();            out.close();        } catch (IOException e) {            e.printStackTrace();  //To change body of catch statement use File | 				//Settings | File Templates.        } finally {        }    }    /**       Creates a file with links to all cities     */    private void createFile() {        try {            FileWriter out = new FileWriter("test.txt");            PrintWriter myOutput = new PrintWriter(out);            Iterator it = cityList.iterator();            String city = "";            while(it.hasNext()){            city = (String) it.next();String thisLine =                        "n" +                                "t t  ""+				city+""n"" +                        ""n"";                              myOutput.write(thisLine);                  myOutput.write(""n"");                  myOutput.flush();            }        } catch (IOException e) {            e.printStackTrace();  //To change body of catch statement use File 				//| Settings | File Templates.        }    }}/** * Main class - class containing the main method */public class Hello {    public static void main(String args[]){        Process process = new Process();    }}

” From: http://sitestree.com/?p=4945
Categories:Java Short Notes
Tags:
Post Data:2013-03-18 14:29:36

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Java Fundamentals #Java Short Notes

  • An abstract class may have constructors
  • It is illegal to invoke the new operator on an abstract class
  • An abstract class is allowed to have method implementations
  • There is no restriction about the placement of abstract classes in a class hierarchy
  • It is legal for an abstract class to implement an interface and implement one or more interface methods
  • A well-encapsulated class must have all of its attributes marked private
  • A well-encapsulated class must hide all internal methods.
  • NOT all attributes require accessor or mutator methods

From: http://sitestree.com/?p=4936
Categories:Java Short Notes
Tags:
Post Data:2008-07-21 09:28:29

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Your First EJB Application #Java Short Notes

From: http://sitestree.com/?p=4935
Categories:Java Short Notes
Tags:
Post Data:2011-11-10 23:41:54

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Java Design Patterns and Examples #Java Short Notes

From: http://sitestree.com/?p=4934
Categories:Java Short Notes
Tags:
Post Data:2007-06-04 16:27:01

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

A simple EJB 3.0 application: Explanation of EJB 3.0 technology: EJB => Spring Framework #Java Short Notes

A simple EJB 3.0 application: Explanation of EJB 3.0 technology: EJB => Spring Framework ……. …. …

From: http://sitestree.com/?p=4933
Categories:Java Short Notes
Tags:
Post Data:2008-05-07 18:54:31

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

EJB 3.0: Specifications : Simplified API #Java Short Notes

  • Focused on annotations – reduces the number of classes and interfaces, eliminates the need for a deployment descriptor
  • Encapsulation of environmental dependencies and JNDI access: annotations, dependency injection, simple lookup mechanism
  • Simpler enterprise bean types
  • session beans: business interface can be a plain Java interface
  • session beans: no need for a home interface
  • entity persistence: Java Persistence API.
  • A query language for Java persistence
  • session beans and message driven beans: an interceptor facility
  • implementation of callback interfaces is not a must
  • Java persistence API: provide object relational mapping, can replace Hibernate
  • A POJO (Plain Old Java Object) programming model
  • A lightweight ORM persistence framework
  • Dependency injection
  • Metadata annotations
  • Configuration by exception
  • Elimination of component interfaces
  • Elimination of home interfaces
  • Reduction of the use of checked exceptions

From: http://sitestree.com/?p=4932
Categories:Java Short Notes
Tags:
Post Data:2009-06-10 02:59:25

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

JSP: Reference Manuals #Java Short Notes

From: http://sitestree.com/?p=4931
Categories:Java Short Notes
Tags:
Post Data:2013-04-10 19:14:41

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Servlet, JSP Specifications #Java Short Notes

From: http://sitestree.com/?p=4930
Categories:Java Short Notes
Tags:
Post Data:2009-10-10 10:47:36

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Essential Knowledge on Web Component Development #Java Short Notes

  • doGet() processes HEAD requests in the absence of a doHead() method
  • Not the service() method but the methods that are called by the service method are better candidates for overriding
  • HttpServlet supports GET, POST, DELETE, OPTIONS, and TRACE requests
  • Retrieve a single value for a form parameter named “username”: String u = request.getParameter(“username”);, String u = request.getParameterValues(“username”)[0];
  • java.util.Enumeration getHeaderNames() – retrieves the complete collection of request headers
  • set the content type of a servlet response:
    response.setContentType(“text/html”);
    response.setHeader(“Content-Type”, “text/html”);
    response.addHeader(“Content-Type”, “text/html”);
  • Servlet.destroy(): Servlets release resources: When called, the servlet container may not route other requests to that instance of the servlet: Servlet.destroy() may never be called
  • The destroy() method, called by the web container when the servlet (or the web application) is being shutdown. This is a very good place to put the code to close related socket connection
  • no guarantee on when the finalize() method will be called by the JVM
  • The init() method is called by the web container before any HTTP requests are processed by the servlet. This is a good place to open a socket connection
  • web.xml, JAR files, Class files, the deployment descriptor – are expected to be placed under WEB-INF directory
  • A welcome file: used when a user requests a directory
  • welcome files may be used at any directory level
  • the default servlet is used to handle requests for specific files that exist in the webapp
  • By default, the web container sends a 404 error back if the requested file does not exist
  • Define a mime-mapping:pdfapplication/pdf
  • WAR files are created using the jar command.
  • A web application may be packaged into a WAR file for deployment, but it is not required.
  • The files within the WEB-INF directory and the files within the META-INF directory of a WAR file must not be directly served as content by the container in response to a Web client’s request.
  • A webapp can only have one web.xml file and all configuration must exist in that one file even if the Java class files exist in some other package
  • String boundObjectName = getServletContext().getInitParameter(“com.example.BoundObj”);:returns a String if an initializathttp://www.justetc.net/knowledge/editArticlesNext.phphttp://www.justetc.net/knowledge/editArticlesNext.phpion parameter of that name exists in web.xml
  • session.removeAttribute(“app.util.DataSource”);: removes a session attribute
  • Servlet context listeners are notified when the context is ready to process requests and when it is about to be shut down
  • HttpSession.setAttribute(String attributeName,Object value): method stores an object

From: http://sitestree.com/?p=4929
Categories:Java Short Notes
Tags:
Post Data:2008-09-09 09:45:43

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

#Sensor: #Canada: #Job/Contract/Project: #Sensor, #Tracking, #Fusion, #Estimation, #Surveillance, #sensor network, #target #tracking, #security 2021-07-18

Date Posted:2021-07-18 .Apply yourself, or submit others as candidates; Build a recruitment team to submit others as candidates; submit RFP to be considered for projects in future; Try to become a vendor so that you are asked to submit consultants/resources in future. If these work for you. This list is posted in this blog everyday provided there are new projects under the criteria

  1. armament-10027
  2. Signal Smoke Marine, Orange (W8486-217390/A)
  3. communications-detection-and-fibre-optics-10031
  4. LEED Recognition Display
  5. construction-products-10032
  6. LEED Recognition Display
  7. electrical-and-electronics-10006
  8. LEED Recognition Display
  9. Surveillance of Space 2 RFI (W8474-187639/C)
  10. fire-fighting-security-and-safety-equipment-10010
  11. Smart Anti-Loitering and Security System
  12. textiles-and-apparel-10028
  13. LEED Recognition Display
  14. architect-and-engineering-services-10048
  15. RFP – Building Perimeter – Access Point Security
  16. communications-photographic-mapping-printing-and-publication-services-10042
  17. LEED Recognition Display
  18. custodial-operations-and-related-services-10037
  19. LEED Recognition Display
  20. environmental-services-10050
  21. LEED Recognition Display
  22. information-processing-and-related-telecommunications-services-10049
  23. LEED Recognition Display
  24. research-and-development-r-d-10036
  25. Surveillance of Space 2 Ground-Based Optical System Request for Information (W8474-207923/B)
  26. ITS Operational Security Services
  27. utilities-10041
  28. LEED Recognition Display
  29. Keywords Used:sensor,fusion,sensor network,tracking,target tracking,surveillance,self driving car,self-driving,estimation,security,signal processing,image processing,autonomouse vehicle,facial recognition,signal,recognition,sensor fusion