Saturday, 19 March 2016

Reading multiple html files into folder parse and store into csv file

Standard


Image result for jsoup
Jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.

Example :

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class HTMLParser {

public static void main(String[] args) {
Document doc = null;

{
FileWriter writer =null;
System.out.println("--------------------------Program started--------------------------");
try {
writer = new FileWriter("c:\\Temp\\abc_search_data.csv");

       File input = new File("C:\\My Web     Sites\\http___www.abcd.com_\\www.abcd.com\\library\\html\\");

File[] st = input.listFiles();

for (int i = 0; i < st.length; i++) {
if (st[i].isFile()) {// other condition like name ends in
// html

// parse(st[i]);

doc = Jsoup.parse(st[i], null);

// get page title
String title = doc.title();
System.out.println("title : " +"["+i+"]"+ title);
//
String ownText = doc.body().ownText();
String text = doc.body().text();
//
//System.out.println("ownText" + ownText + "\n");
//System.out.println("text" + text);
//
 
     writer.append("title : "+"["+i+"]");
     writer.append(',');
     writer.append(title);
     writer.append('\n');

    /* writer.append("ownText");
     writer.append(',');
     writer.append(ownText);
     writer.append('\n');*/
     
     writer.append("text : "+"["+i+"]");
     writer.append(',');
     writer.append(text);
       writer.append('\n');

}
}
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
writer.flush();
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
System.out.println("--------------------------Program End--------------------------");
}

}

Tuesday, 15 March 2016

Magic Tool JHpster

Standard
What Is JHipster?


 +  +  = 
The term 'JHipster' comes from 'Java Hipster', as its initial goal was to use all the modern and 'hype' tools available at the time.[Today, it has reached a more enterprise goal, with a strong focus on developer productivity, tooling and quality.
Major functionalities
  • Generate a full stack application, with many options
  • Generate CRUD entities
  • Database migrations with Liquibase
  • NoSQL databases support (Cassandra, MongoDB)
  • Elasticsearch support
  • Websockets support
  • Automatic deployment to CloudFoundry, Heroku, OpenShift

Technology stack
  • HTML5 Boilerplate
  • Twitter Bootstrap
  • AngularJS
  • Full internationalization support with Angular Translate
  • Optional Compass / Sass support for CSS design
  • Optional WebSocket support with Spring Websocket
On the server side:
  • Spring Boot
  • Spring Security
  • Spring MVC REST + Jackson
  • Monitoring with Metrics
  • Optional WebSocket support with Spring Websocket
  • Spring Data JPA + Bean Validation
  • Database updates with Liquibase
  • Elasticsearch support
  • MongoDB support
Out-of-the-box auto-configured tooling:
  • Yeoman
  • Grunt or Gulp.js
  • BrowserSync
  • Maven or Gradle


jHipster, generates full stack web application using Angular and Spring ! Look at the great questions it asks when creating jHipster application !
Imagine the comfort you get by having all these dependencies in your app right there when you start the development !
Hmm.. There are so many technologies embedded as a inherient part of jHipster.
HTML5BoilerPlate- So you dont have to worry adding things like Modernizer on your own. This boiler plate takes care of old browsers too, so many old-school browsers got taken care of.
Twitter Bootstrap: Need to talk anything about this most popular project on Github ?
Bower: Dependency management on client side ! Very popular now a days !
Karma, PhantomJS: When it is angular, no need to really mention this as it comes part of Angular. But just not to forget !
Following on server side !
Boot should be mentioned again and again because Boot was mentioned again and again in this year's SpringOne (which I did not attend btw :) , for architecture style of Micro-service. Spring guys have Boot everywhere now a days !
And when it is Spring world, I dont have to mention Spring Security, Spring MVC etc Right ?
I am also so much impressed with what jHipster has for production readiness ! Monitoring with Metrix (which I dont know !) , caching with something called HazerCast (sorry, Dont kno

JHipster is a Yeoman generator, used to create a Spring Boot + AngularJS project. 
JHipster provides tools to generate a project with a Java stack on the server side (using Spring Boot) and a responsive Web front-end on the client side (with AngularJS and Bootstrap).
What is the base name of your application?
Would you like to use Maven or Gradle? -So, decide your server side build manager 
What is your default Java package name?
Do you want to use Java 8? -Cool !
Which *type* of authentication would you like to use? -Superb ! You can also choose OAuth
Which *type* of database would you like to use?SQL / NoSQL ?
Do you want to use Hibernate 2nd level cache? -Hardcore server side engineers know how it helps !
Do you want to use clustered HTTP sessions?So by default, very minimal in session, almost stateless which is need for scalability.
Do you want to use WebSockets?Applause 
Which *production* database would you like to use?Means, you can have different databases already configured in production and development.
Which *development* database would you like to use?
Would you like to use Grunt or Gulp.js for building the frontend?Cool - Options here too Would you like to use the Compass CSS Authoring Framework?Incredible ! Compass is most advanced tool to generate CSS.

Sakai

Standard

Sakai is a freecommunity source, educational software platform designed to support teaching, research and collaboration. Systems of this type are also known as Course Management Systems (CMS), Learning Management Systems (LMS), or Virtual Learning Environments (VLE). Sakai is developed by a community of academic institutions, commercial organizations and individuals. It is distributed under the Educational Community License (a type of open source license).


Sakai setup

1) download java 8
2) download tomca t8
3) download sakai 10 demo

Set environment variable  

CATALINA_HOME
C:\apache-tomcat-8.0.30
JAVA_HOME
C:\Program Files\Java\jdk1.8.0_65
JRE_HOME
C:\Program Files\Java\jre1.8.0_66
PATH
C:\Users\vaqua_000\AppData\Roaming\npm;C:\Program Files\Java\jdk1.8.0_65\bin;C:\Program Files (x86)\Java\jre1.8.0_66\bin;C:\apache-tomcat-8.0.30\bin


Go to oracle.com and install java jre 8(check not be installed java 6 plz)

After that go to C:/Program files/java/jre8/bin

Here create an folder called "Server" (without " ")

Now go into the C:/Program files/java/jre7/bin/client folder

COPY all data of this folder into the new C:/Program files/java/jre8/bin/Server



Wait 10 min to start tomcat server then open in  browser 


Default sakai password is admiin/admin