Pages Navigation Menu

Coding is much easier than you think

RECENT POSTS

How To Change The File Last Modified Date In Java?

Posted by in Java

How To Change The File Last Modified Date In Java?

  Here’s an example to change the file’s last modified date with the help of File.setLastModified() . This method accept the new modified date in milliseconds (long type), So some data type conversion are required.   import java.io.File; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class ChangeFileLastModifiedDate { public static void main(String[] args) { try { File file = new File("C:\File.pdf"); // Print the original last modified...

read more

How To Get The File’€™s Last Modified Date & time In Java?

Posted by in Java

  In Java, you can use the File.lastModified() to get the file’€™s last modified timestamps. This method will returns the time in milliseconds (long value), you may to format it with SimpleDateFormat to make it a human readable format. File Last Modified Date and Time   import java.io.File; import java.text.SimpleDateFormat; public class GetFileLastModifiedDate { public static void main(String[] args) { File file = new File("c:\Core java.ppt"); System.out.println("Before Format : " +...

read more

How to find or check hidden files in Java ?

Posted by in Java

How to find or check hidden files in Java ?

  we can check the file property is hidden or not and accordingly we can use that file in our application. isHidden() method is provided on file Class in Java which we will use to test this property.   Syntax of the method:   public static boolean isHidden(Path path) throws IOException   Here we pass the path of the file for which we want to test hidden property and it will return true if it’€™s a hidden file otherwise will get false value. Here is complete code example of finding hidden file in Java, we are using...

read more

How to call Android contacts list and Display his name and Phone Number after selection?

Posted by in Android

How to call Android contacts list and Display his name and Phone Number after selection?

There are three steps to this process. 1) Permissions Add a permission to read contacts data to your application manifest. 2) Calling the Native Contact Picker Android already has behavior built in to select contacts. This is used to select contacts for phone calls and other native apps. But it can also be used by apps like yours so you don’€™t have top build it yourself. Intents are a generic mechanism for invoking an action that the system can respond to. When the Android action code processed that Intent, it saw the reference to...

read more

How to get a list of installed android applications in Android

Posted by in Android

How to get a list of installed android applications in Android

Starting from the your Activity context you can obtain an instance of PackageManager through the method called  getPackageManager(). Using that class is it possible to get a list of ApplicationInfo objects containing details about apps such as MetaData, Permissions, Services or Activities. Flag are very import for PackageManager .For example  PackageManager.GET_META_DATA will retrieve only meta data for all packages . Useful data are for example the name of the app, the packageName used to retrieve additional information with...

read more

How To Escape Special Characters of JSP using Java code?

Posted by in Java

How To Escape Special Characters of JSP using Java code?

  Often times, we encountered some special characters or arbitrary text placed in an HTML tag that resulting an invalid HTML output. The special characters often needs to be altered or escape to ensure the resulting HTML is still valid. Special characters as follow 1) < 2) > 3) \ 4) & StringEscapeUtils which included in commons-lang.jar library, is used to escape special characters in Java. Here is the source code to demonstrate how to escape special characters with StringEscapeUtils class.   import...

read more

Struts 2 ModelDriven Example

Posted by in Struts 2 Tutorial, Struts-2

Struts 2 ModelDriven Example

  In our last article we have learned how to use a JavaBean class as a property in struts 2 action.   In this tutorial we will learn about Struts 2 support for model objects.   The Model object is a simple JavaBean object, which will be available to action class directly from ValueStack, i.e we dont need to do deeper referencing to refer its attribute(JavaBeans attribute).   To make a JavaBean object as a model object, our Action class should implement ModelDriven interface which forces the getModel() method to be...

read more

Different ways to write struts 2 action class

Posted by in Struts 2 Tutorial, Struts-2

Different ways to write struts 2 action class

  The functionality of the action class is to retrieve resource bundle, hold the data, provide validation, perform business logic and select the view result page that should be sent back to the user. There are four different ways to write struts 2 action class , which are as follows   1. Action   For Struts 2 actions, it is not mandatory to implement any interface or extend any class. It is only required to implement execute() method that returns a string which is to be used in struts.xml, to indicate the result page that has to...

read more

Struts 2 ActionError & ActionMessage Example

Posted by in Struts 1, Struts 2 Tutorial, Struts-2 | 1 comment

Struts 2 ActionError & ActionMessage Example

  In this tutorial we will learn about ActionError & ActionMessage class and its usage.   a) ActionError class is used to send error feedback message to user and it get rendered in jsp by using <s:actionerror/> tag as shown below.   <s:if test="hasActionErrors()"> <s:actionerror/> </s:if>   b) ActionMessage class – is used to send information feedback message to user, and it get rendered in jsp using <s:actionmessage/> tag as shown below.   <s:if...

read more

Struts 2 Tutorial for beginners

Posted by in Struts 2 Tutorial, Struts-2 | 22 comments

Struts 2 Tutorial for beginners

  Introduction to Struts 2 Framework   In this course we will learn how to use Struts 2 to create an MVC based Java web application. Struts 2 is a framework for developing MVC based web applications in Java. When building a complex web application it is often difficult to keep business and view logic separate from each other. In this course we will learn how to create a Java based web application using the Struts 2 MVC framework to cleanly separate our views from business logic. We will cover important features of Struts 2 like...

read more