ARTICLE

demo2

10-09-2016
Write the article  ghjghjg  gbhjghjhg ghjgh

Code for Reading a xlsx file in java

12-06-2014
You may need to include some of the jar files like xmlbeans-2.3.0.jar dom4j-1.1.jar poi-ooxml-schemas-3.6-20091214.jar poi-ooxml-3.6-20091214.jar poi-3.6-20091214.jar You can google it and download and include it along with the below code. You have to include a simple xlsx file with some values in it (string values) and run the code. This code will fetch the values and print it on the screen.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import org.apache.poi.xssf.usermodel.XSSFWorkbook; 
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import java.util.Iterator;
import java.io.*;
public class Main {
 
 
    public void ReadSheet() throws Exception
    {
        String filename = "book1.xlsx";
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(filename);
            
            XSSFWorkbook workbook = new XSSFWorkbook(fis);
            XSSFSheet sheet = workbook.getSheetAt(0);
            Iterator rows = sheet.rowIterator();
            int number=sheet.getLastRowNum();
            System.out.println(" number of rows"+ number);
            while (rows.hasNext())
            {
 
                XSSFRow row = ((XSSFRow) rows.next());
                Iterator cells = row.cellIterator();
                while(cells.hasNext())
                {
                    XSSFCell cell = (XSSFCell) cells.next();
                    String Value=cell.getStringCellValue();
                    System.out.println(Value);
                }
             }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
                fis.close();
            }
        }
       
    }
 
 
    public static void main(String[] args) {
 
        Main object=new Main();
        try{
        object.ReadSheet();
 
        }catch(Exception e)
        {
            e.printStackTrace();
        }
}
 
}
Similarly you can do for the numeric cells. Or i will paste a different code for it. Leave a comment if you need some help.

Basic example on Spring WebServices using Maven

09-06-2013
This is a very basic example on spring webservices purely built on spring. In this example we have use maven to build, apache tomcat as a server. JAXB is used to convert xsd's to java classes. EndPoints are used for minimal configuration to handle incoming request. MessageDispatcher Servlet is used to deliver the soap messages to the endpoints The complete code is available at https://github.com/ankurgoel11/Spring-WS-Basic We will walkthrough the important parts of the code. I have named the project as spring-ws1 There are many ways to create a project. I have created all the directories manually and they are like given below: http://www.gradfather.com/blog/wp-content/uploads/2012/05/Screen-Shot-2012-05-03-at-8.46.07-PM.png         After Creating the above directory structure open the eclipse and perform the below steps: Step 1:        After performing all the above steps you can see the project in your eclipse. Now you have to write the code in eclipse. Open the file pom.xml at the root of the folder and put the below text. Pom.xml will download all the libraries from the internet and generate the java file from the xsd file. All the required libraries will be downloaded and added to eclipse. The plugin in the below pom.xml willl generate java classes for the xsd files present.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?xml version="1.0" encoding="UTF-8"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<groupId>spring-example1</groupId>
	<artifactId>example1</artifactId>
	<packaging>war</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>SpringOne</name>
	<dependencies>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>3.0.5.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>3.0.5.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.ws</groupId>
			<artifactId>spring-ws-core</artifactId>
			<version>2.0.2.RELEASE</version>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>com.sun.tools.xjc.maven2</groupId>
				<artifactId>maven-jaxb-plugin</artifactId>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<components>
								<component>
									<name>generate</name>
									<outputDirectory>/src/main/java</outputDirectory>
								</component>
							</components>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<generatePackage>schema</generatePackage>
					<generateDirectory>src/main/java/</generateDirectory>
					<schemaDirectory>src/main/webapp/WEB-INF/xsd/</schemaDirectory>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
  Now Create the web.xml with the below code. We have defined a servlet MessageDispatcherServlet specifically designed for SOAP messages  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
	<display-name>spring1</display-name>
	<servlet>
		<servlet-name>spring-ws</servlet-name>
		<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet
		</servlet-class>
		<init-param>
			<param-name>transformWsdlLocations</param-name>
			<param-value>true</param-value>
		</init-param>
	</servlet>

	<servlet-mapping>
		<servlet-name>spring-ws</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>

</web-app>
  Create a file with the below code spring-ws-servlet.xml. As the servlet name is spring-ws in the web.xml so we have to name the file as spring-ws-servlet.xml. In this file we have created beans and defined required classes.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:sws="http://www.springframework.org/schema/web-services"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-1.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

	<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
		<property name="xsd" value="/WEB-INF/xsd/user.xsd" />
	</bean>

	<oxm:jaxb2-marshaller id="marshaller" contextPath="schema" />

	<bean id="annotationMapping"
		class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
	</bean>

	<bean id="userEndPoint" class="UserLoginEndPoint" />

	<sws:marshalling-endpoints />

	<context:annotation-config />

	<bean id="user"
		class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
		<property name="schema" ref="schema" />
		<property name="portTypeName" value="User" />
		<property name="locationUri" value="/userService" />
	</bean>

</beans>
  Create the file user.xsd with the below code.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.gradfather.com/user"
	xmlns:tns="http://www.gradfather.com/user" elementFormDefault="qualified">

	<element name="SupplyUserCredentialsRequest">
		<complexType>
			<sequence>
				<element name="LoginId" type="string" />
				<element name="Password" type="string" />
			</sequence>
		</complexType>
	</element>

	<element name="UserCredentialsResponse">
		<complexType>
			<sequence>
				<element name="result" type="string" />
			</sequence>
		</complexType>
	</element>
</schema>
Create the file UserLoginEndPoint.java to handle request and send back response  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;

import schema.SupplyUserCredentialsRequest;
import schema.UserCredentialsResponse;

@Endpoint
public class UserLoginEndPoint
{
	@PayloadRoot(localPart = "SupplyUserCredentialsRequest", namespace = "http://www.gradfather.com/user")
	public UserCredentialsResponse authenticateUser(SupplyUserCredentialsRequest request)
	{
		UserCredentialsResponse a = new UserCredentialsResponse();
		if (request.getLoginId().equalsIgnoreCase("a") && request.getPassword().equalsIgnoreCase("a"))
		{
			a.setResult("true");
		} else
			a.setResult("false");
		return a;
	}
}
Now compile the project from the command prompt using maven with the below 2 commands: mvn clean eclipse:eclipse mvn install Now deploy the war file on the tomcat server. If you do not get the option as run on server or does not list in the add or remove on the right click of the server. Then export the project as war file and put the war file in the webapps folder. It will be auto deployed. Hit the url: http://localhost:8080/example1/UserService/user.wsdl You will see the wsdl generated. Now open the soap ui and create the project with the above wsdl. Then create a request and send it, you will see a flying response coming in. Please do leave your feedback.

Spring-WebServices using maven, hibernate basic example (hello world)

09-06-2013
This example is based on spring, hibernate, maven, webservices, apache-tomcat, DetachedCriteria, orm, EndPoints. Api used in this examples are:
  1. org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition
  2. org.springframework.jdbc.datasource.DriverManagerDataSource
  3. org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping
  4. org.springframework.xml.xsd.SimpleXsdSchema
  5. org.springframework.orm.hibernate3.HibernateTransactionManager
  6. org.springframework.orm.hibernate3.LocalSessionFactoryBean
  7. DetachedCriteria
  8. org.springframework.ws.transport.http.MessageDispatcherServlet
The project structure used in eclipse is shown below: The name of the project is spring-ws3, but one can give any name. The code of all the files are: pom.xml  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?xml version="1.0" encoding="UTF-8"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<groupId>spring-example1</groupId>
	<artifactId>example1</artifactId>
	<packaging>war</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>SpringOne</name>
	<dependencies>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>3.0.5.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>3.0.5.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api</artifactId>
			<version>2.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.ws</groupId>
			<artifactId>spring-ws-core</artifactId>
			<version>2.0.2.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>commons-dbcp</groupId>
			<artifactId>commons-dbcp</artifactId>
			<version>1.4</version>
		</dependency>

		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>3.6.9.Final</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
			<version>3.1.0.RELEASE</version>
		</dependency>

		<dependency>
			<groupId>javassist</groupId>
			<artifactId>javassist</artifactId>
			<version>3.12.1.GA</version>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.19</version>
		</dependency>

	</dependencies>
	<build>
		<plugins>

			<plugin>
				<groupId>com.sun.tools.xjc.maven2</groupId>
				<artifactId>maven-jaxb-plugin</artifactId>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<components>
								<component>
									<name>generate</name>
									<outputDirectory>/src/main/java</outputDirectory>
								</component>
							</components>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<generatePackage>schema</generatePackage>
					<generateDirectory>src/main/java/</generateDirectory>
					<schemaDirectory>src/main/webapp/WEB-INF/xsd/</schemaDirectory>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
web.xml  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
	<display-name>spring1</display-name>
	<servlet>
		<servlet-name>spring-ws</servlet-name>
		<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet
		</servlet-class>
		<init-param>
			<param-name>transformWsdlLocations</param-name>
			<param-value>true</param-value>
		</init-param>
	</servlet>

	<servlet-mapping>
		<servlet-name>spring-ws</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>
</web-app>
spring-ws-servlet.xml  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:sws="http://www.springframework.org/schema/web-services"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-1.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

	<bean id="datasourcebean"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="mysqldatabase" />
		<property name="mappingResources">
			<list>
				<value>com/test.hbm.xml</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
				<prop key="hibernate.format_sql">true</prop>
				<prop key="hibernate.show_sql">true</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="datasourcebean" />
	</bean>

	<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
		<property name="xsd" value="/WEB-INF/xsd/user.xsd" />
	</bean>

	<oxm:jaxb2-marshaller id="marshaller" contextPath="schema" />

	<bean id="annotationMapping"
		class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping">
	</bean>

	<bean id="userEndPoint" class="com.UserLoginEndPoint">
		<constructor-arg ref="datasourcebean" />
	</bean>

	<sws:marshalling-endpoints />

	<context:annotation-config />

	<bean id="user"
		class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
		<property name="schema" ref="schema" />
		<property name="portTypeName" value="User" />
		<property name="locationUri" value="/userService" />
	</bean>

	<bean id="mysqldatabase"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>jdbc:mysql://localhost:3306/test</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password">
			<value></value>
		</property>
	</bean>
</beans>
UserLoginEndPoint.java  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Expression;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;

import schema.SupplyUserCredentialsRequest;
import schema.UserCredentialsResponse;

@Endpoint
public class UserLoginEndPoint
{

	private HibernateTemplate hibernateTemplate;

	public UserLoginEndPoint(SessionFactory sf)
	{
		setSessionFactory(sf);
	}

	public void setSessionFactory(SessionFactory sessionFactory)
	{
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	@PayloadRoot(localPart = "SupplyUserCredentialsRequest", namespace = "http://www.gradfather.com/user")
	public UserCredentialsResponse authenticateUser(SupplyUserCredentialsRequest request)
	{
		UserCredentialsResponse a = new UserCredentialsResponse();
		System.out.println(this.hibernateTemplate);
		Test object = new Test();

		object.setName("ankur");

		System.out.println("Something printer");

		DetachedCriteria ct = DetachedCriteria.forClass(Test.class);

		String tt = "Something";

		ct.add(Expression.eq("name", tt));

		List<Test> objectList = hibernateTemplate.findByCriteria(ct);

		if (request.getLoginId().equalsIgnoreCase("a") && request.getPassword().equalsIgnoreCase("a"))
		{
			a.setResult("" + objectList.size());
		} else
			a.setResult("false");
		return a;
	}
}
Test.java  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com;

import java.io.Serializable;

public class Test implements Serializable
{

	private static final long serialVersionUID = 1L;

	private int id;

	private String name;

	private int age;

	public void setId(int id)
	{
		this.id = id;
	}

	public int getId()
	{
		return this.id;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getName()
	{
		return this.name;
	}

	public void setAge(int age)
	{
		this.age = age;
	}

	public int getAge()
	{
		return age;
	}

}
test.hbm.xml  
1
2
3
4
5
6
7
8
9
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com">
	<class name="Test" table="employees">
		<id name="id" column="id"/>
		<property name="age" column="age" />
		<property name="name" column="name"></property>
	</class>
</hibernate-mapping>
user.xsd  
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.gradfather.com/user"
	xmlns:tns="http://www.gradfather.com/user" elementFormDefault="qualified">

	<element name="SupplyUserCredentialsRequest">
		<complexType>
			<sequence>
				<element name="LoginId" type="string" />
				<element name="Password" type="string" />
			</sequence>
		</complexType>
	</element>

	<element name="UserCredentialsResponse">
		<complexType>
			<sequence>
				<element name="result" type="string" />
			</sequence>
		</complexType>
	</element>
</schema>
We have used the mysql database. There is a schema name 'test' and the table name 'employee'. The primary key of the table is id. There are more 2 columns named 'age' and 'name'.   After creating the above code in your eclipse you can build the code and deploy it using maven and apache-tomcat. I have prepared the war file and named it as example1.war so the url where the wsdl is present: http://localhost:8080/example1/UserService/user.wsdl Execute the below soap request and see the response comming. The soap request:  
1
2
3
4
5
6
7
8
9
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://www.gradfather.com/user">
   <soapenv:Header/>
   <soapenv:Body>
      <user:SupplyUserCredentialsRequest>
         <user:LoginId>a</user:LoginId>
         <user:Password>a</user:Password>
      </user:SupplyUserCredentialsRequest>
   </soapenv:Body>
</soapenv:Envelope>
For this example you have to put some data in the database. Please post questions if any.

Read File in a String object all at once in java

09-06-2013
To read all the contents of the file in a String in java all at once. This Should only be used when the file size is small otherwise heap space could throw error. Please see the below code snippet and mail me if any issues:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
BufferedReader reader = new BufferedReader( new FileReader ("flags.txt"));
	    String line  = null;
	    StringBuilder stringBuilder = new StringBuilder();
	    String ls = System.getProperty("line.separator");
	    while( ( line = reader.readLine() ) != null ) {
	        stringBuilder.append( line );
	        stringBuilder.append( ls );
	    }
	    String content1=stringBuilder.toString();
	    System.out.println(content1);