import java.io.File; public class CreateFolder { public static void main(String[] args) { File file = new File("C:\\Folder"); if (!file.exists()) { if (file.mkdir()) { System.out.println("Folder is created!"); } else { System.out.println("Failed to create Folder!"); } } File files = new File("C:\\Folder1\\Sub1\\Sub-Sub1"); if (files.exists()) { if (files.mkdirs()) { System.out.println("Multiple Folders are created!"); } else { System.out.println("Failed to create multiple Folders!"); } } } }
Monday, 22 June 2015
How to create Folder in Java
Monday, 15 June 2015
Creating File in java
import java.io.File;
import java.io.IOException;
public class WriteInFile {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
File f = new File("d:\\newfile.txt"); // path to create file
if (f.createNewFile()){
System.out.println("file created");
}else{
System.out.println("file is their");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.IOException;
public class WriteInFile {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
File f = new File("d:\\newfile.txt"); // path to create file
if (f.createNewFile()){
System.out.println("file created");
}else{
System.out.println("file is their");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Sunday, 14 June 2015
Using custom properties file in jsp and java files for dynamic work(In Liferay 6.2)
Properties prop = new Properties();
FileInputStream inputStream = new FileInputStream("/path of the file");
prop.load(inputStream);
U can keep properties file location src else tomcat bundle
Thursday, 11 June 2015
Embedding One portlet in Another (Liferay 6.2)
Write Below Lines in Jsp Page
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<liferay-portlet:runtime portletName="82" />
Where 82 is portlet Id
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<liferay-portlet:runtime portletName="82" />
Where 82 is portlet Id
Tuesday, 9 June 2015
How to Increase the size of Column in Liferay?
By Default Size of Column(Data type String ) is 75..
If We Want Increase this size write the sentence like below in portlet-model-hints.xml under
docroot/WEB-INF/SRC/META-INF
and build service.xml once......
If We Want Increase this size write the sentence like below in portlet-model-hints.xml under
docroot/WEB-INF/SRC/META-INF
<field name="description" type="String">
<hint name="max-length">500</hint>
</field>
and build service.xml once......
Friday, 5 June 2015
Sorting Column in Search Container
- Write orderable and orderableProperty for column like below
<liferay-ui:search-container-column-text name="Start Date" property="startDate" orderable="true" orderableProperty="startDate"/>
- Write render Method in controller class
@Override
public void render(RenderRequest request, RenderResponse response)
throws IOException, PortletException {
//System.out.println("hello1");
setSortParams(request);
super.render(request, response);
}
private void setSortParams(RenderRequest request) {
String jspPage = ParamUtil.getString(request, "jspPage");
//System.out.println("hello"+jspPage);
if (jspPage.equalsIgnoreCase(ProjectConstants.PAGE_PROJECT)) {
String orderByCol = ParamUtil.getString(request, "orderByCol",
"projectId");
request.setAttribute("orderByCol", orderByCol);
String orderByType = ParamUtil.getString(request, "orderByType",
"asc");
request.setAttribute("orderByType", orderByType);
//System.out.println("hello"+orderByCol+"aa"+orderByType);
}
}
- In JSP Page
List<Projects> projects = ProjectsLocalServiceUtil.getProjectses(0, ProjectsLocalServiceUtil.getProjectsesCount());
String orderByCol = (String) request.getAttribute("orderByCol");
String orderByType = (String) request.getAttribute("orderByType");
BeanComparator comp = new BeanComparator(orderByCol);
List<Projects> projectsResults = ListUtil.copy(projects);
Collections.sort(projectsResults, comp);
//System.out.print("column:"+orderByCol);
//System.out.print("type:"+orderByType);
if (orderByType.equalsIgnoreCase("desc")) {
Collections.reverse(projectsResults);
}
- At Last add this attributes
<liferay-ui:search-container orderByCol="<%= orderByCol %>" orderByType="<%= orderByType %>" >
</liferay-ui:search-container>
Thursday, 4 June 2015
Interface Concept In java
INTERFACE
- A Java interface is a bit like a class, except a Java interface can only contain method signatures and fields
- An Java interface cannot contain an implementation of the methods, only the signature (name, parameters and exceptions) of the method.
- You can use interfaces in Java as a way to achieve polymorphism.
For Exa.
public interface MyInterface { public String hello = "Hello"; //parameter public void sayHello(); // method signature }
Subscribe to:
Posts (Atom)