Tuesday, 27 December 2016
Making Image as a Link
HTML:
<div id="content">
<h2>Report Collection Link</h2>
<a href="Development.htm">
<img src="D:\report\sun.png" alt="sun" style="width:100px; height:100px; border:0;vertical-align:middle"></a>
</div>
CSS:
#content{
margin: 30px 0;
background: white;
padding: 20px;
clear: both;
}
<div id="content">
<h2>Report Collection Link</h2>
<a href="Development.htm">
<img src="D:\report\sun.png" alt="sun" style="width:100px; height:100px; border:0;vertical-align:middle"></a>
</div>
CSS:
#content{
margin: 30px 0;
background: white;
padding: 20px;
clear: both;
}
Set Logo for HTML Page
style:
.header img {
float: left;
width: 100px;
height: 100px;
background: #555;
}
.header h1 {
position: relative;
top: 18px;
left: 10px;
}
html:
<div class="header">
<img src="img/logo.png" alt="logo" />
<h1>My website name</h1>
</div>
.header img {
float: left;
width: 100px;
height: 100px;
background: #555;
}
.header h1 {
position: relative;
top: 18px;
left: 10px;
}
html:
<div class="header">
<img src="img/logo.png" alt="logo" />
<h1>My website name</h1>
</div>
Monday, 26 December 2016
Moving Files From One Folder to Another Folder
1)create maveen project
2)import lib files from commons-io2.0.1.jar for FileUtils,FilenameUtils
by downloading from following link
https://commons.apache.org/proper/commons-io/download_io.cgi
3) make sure destination and source folder path
package JavaWorld;
import java.io.File;
//commons-io2.0.1.jar for FileUtils,FilenameUtils
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
public class MoveFilesBasedOnExtension {
public static void main(String a[])throws Exception
{
File srcFolder = new File("C:/Users/Vishnuyardini/Desktop/fotos/11-12-16 soulmates to banshankari ashram");
File processedDir = new File("C:/Users/Vishnuyardini/Desktop/fotos/soulmate siritual trip");
File shdir = new File("C:/Users/Vishnuyardini/Desktop/fotos/soulmate siritual trip/shdir");
File afile[];
int j = (afile = srcFolder.listFiles()).length;
for(int i = 0; i < j; i++)
{
File fileEntry = afile[i];
String fileName = fileEntry.getName();
System.out.println(fileName);
//moving specific files to other destination directory
if("jpg".equalsIgnoreCase(FilenameUtils.getExtension(fileName)))
{
FileUtils.moveFileToDirectory(fileEntry, processedDir, true);
}
if("txt".equalsIgnoreCase(FilenameUtils.getExtension(fileName)))
{
FileUtils.moveFileToDirectory(fileEntry, shdir, true);
}
}
}
}
Output:
before:
2)import lib files from commons-io2.0.1.jar for FileUtils,FilenameUtils
by downloading from following link
https://commons.apache.org/proper/commons-io/download_io.cgi
3) make sure destination and source folder path
package JavaWorld;
import java.io.File;
//commons-io2.0.1.jar for FileUtils,FilenameUtils
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
public class MoveFilesBasedOnExtension {
public static void main(String a[])throws Exception
{
File srcFolder = new File("C:/Users/Vishnuyardini/Desktop/fotos/11-12-16 soulmates to banshankari ashram");
File processedDir = new File("C:/Users/Vishnuyardini/Desktop/fotos/soulmate siritual trip");
File shdir = new File("C:/Users/Vishnuyardini/Desktop/fotos/soulmate siritual trip/shdir");
File afile[];
int j = (afile = srcFolder.listFiles()).length;
for(int i = 0; i < j; i++)
{
File fileEntry = afile[i];
String fileName = fileEntry.getName();
System.out.println(fileName);
//moving specific files to other destination directory
if("jpg".equalsIgnoreCase(FilenameUtils.getExtension(fileName)))
{
FileUtils.moveFileToDirectory(fileEntry, processedDir, true);
}
if("txt".equalsIgnoreCase(FilenameUtils.getExtension(fileName)))
{
FileUtils.moveFileToDirectory(fileEntry, shdir, true);
}
}
}
}
Output:
before:
after:
List the files in the folder
package JavaWorld;
import java.io.File;
public class ListFileInFolder {
public static void main(String[] args) {
File myFolder = new File("C:/Users/Vishnuyardini/Desktop");
File afile[];
int j = (afile = myFolder.listFiles()).length;
for(int i = 0; i < j; i++)
{
File fileEntry = afile[i];
String fileName = fileEntry.getName();
System.out.println(fileName);
}
}
}
output:
import java.io.File;
public class ListFileInFolder {
public static void main(String[] args) {
File myFolder = new File("C:/Users/Vishnuyardini/Desktop");
File afile[];
int j = (afile = myFolder.listFiles()).length;
for(int i = 0; i < j; i++)
{
File fileEntry = afile[i];
String fileName = fileEntry.getName();
System.out.println(fileName);
}
}
}
output:
Real Guru
Real Guru | |
Master teaches that while there are innumerable gurus, the real guru is none but God Himself. It is the duty of each guru to lead his disciple to the next higher one when his own work with the disciple is finished. No guru should hold his disciples to himself possessively. A guru is for service to others and not for building up possessions, power and prestige for himself. |
Sunday, 25 December 2016
Spiritual Food
Spiritual Food | ||
The soul, being spiritual in nature, needs food of that plane. I was a bit puzzled as to how the same power [transmission] could do everything Master claimed it could achieve, at all levels of development. I put this question to Master. Master laughed amusedly and said, "When we plant a seed, we water it; when it comes up as a small seedling, we water it; when it is a strong plant, we water it; and we go on watering it all its life. The same water achieves the growth of the plant, stage after stage." |
No Karma
No Karma | |
In our Mission we call karma by another word, 'samskara.' And it is not only the bad actions which lead to karma, it is also good actions. Good actions give rise to a good future, whereas bad actions give rise to a bad future. But our idea of spiritual development is to have no future life at all. I mean this sort of life, in the physical plane of existence, we don't want it at all. Nor do we seek to live in other planes. The idea is to be liberated. |
Friday, 23 December 2016
Read Content From Excel File and Write In .txt File
step 1: download selenium
step 2:download Apache poi
step 3:create excel file with content
step 4:create txt document
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class ReadExcel {
public static void main( String [] args ) {
Writer writer = null;
try {
String filePath= System.getProperty("user.dir")+"\\file\\readExcel.xls";
//String sheetName="sheet1";
//File file = new File(filePath);
//FileInputStream inputStream = new FileInputStream(filePath);
InputStream input = new BufferedInputStream(
new FileInputStream(filePath));
POIFSFileSystem fs = new POIFSFileSystem( input );
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0); //sheet of excel
String filePath2= System.getProperty("user.dir")+"\\file\\write.txt";
File file = new File(filePath2);
writer = new BufferedWriter(new FileWriter(file));
Iterator rows = sheet.rowIterator();
while( rows.hasNext() ) {
HSSFRow row = (HSSFRow) rows.next();
System.out.println("\n");
Iterator cells = row.cellIterator();
writer.write("insert into Emp values(");
while( cells.hasNext() ) {
HSSFCell cell = (HSSFCell) cells.next();
if(HSSFCell.CELL_TYPE_NUMERIC==cell.getCellType()) {
System.out.print( cell.getNumericCellValue()+" "+cell.getColumnIndex() );
if(cell.getColumnIndex()==3)
writer.write(String.valueOf(cell.getNumericCellValue()));
else
writer.write(String.valueOf(cell.getNumericCellValue()+","));
}
else
if(HSSFCell.CELL_TYPE_STRING==cell.getCellType()) {
System.out.print( cell.getStringCellValue()+" " );
writer.write("'"+cell.getStringCellValue()+"',");
}
else
if(HSSFCell.CELL_TYPE_BOOLEAN==cell.getCellType()) {
System.out.print( cell.getBooleanCellValue()+" " );
writer.write("'"+String.valueOf(cell.getBooleanCellValue()+"',"));
}
else
if(HSSFCell.CELL_TYPE_BLANK==cell.getCellType())
System.out.print( "BLANK " );
else
System.out.print("Unknown cell type");
}
writer.write(");"+"\n");
}
} catch ( IOException ex ) {
ex.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
} }
catch (IOException e) {
e.printStackTrace();
}
}
}
}
step 2:download Apache poi
step 3:create excel file with content
step 4:create txt document
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public class ReadExcel {
public static void main( String [] args ) {
Writer writer = null;
try {
String filePath= System.getProperty("user.dir")+"\\file\\readExcel.xls";
//String sheetName="sheet1";
//File file = new File(filePath);
//FileInputStream inputStream = new FileInputStream(filePath);
InputStream input = new BufferedInputStream(
new FileInputStream(filePath));
POIFSFileSystem fs = new POIFSFileSystem( input );
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0); //sheet of excel
String filePath2= System.getProperty("user.dir")+"\\file\\write.txt";
File file = new File(filePath2);
writer = new BufferedWriter(new FileWriter(file));
Iterator rows = sheet.rowIterator();
while( rows.hasNext() ) {
HSSFRow row = (HSSFRow) rows.next();
System.out.println("\n");
Iterator cells = row.cellIterator();
writer.write("insert into Emp values(");
while( cells.hasNext() ) {
HSSFCell cell = (HSSFCell) cells.next();
if(HSSFCell.CELL_TYPE_NUMERIC==cell.getCellType()) {
System.out.print( cell.getNumericCellValue()+" "+cell.getColumnIndex() );
if(cell.getColumnIndex()==3)
writer.write(String.valueOf(cell.getNumericCellValue()));
else
writer.write(String.valueOf(cell.getNumericCellValue()+","));
}
else
if(HSSFCell.CELL_TYPE_STRING==cell.getCellType()) {
System.out.print( cell.getStringCellValue()+" " );
writer.write("'"+cell.getStringCellValue()+"',");
}
else
if(HSSFCell.CELL_TYPE_BOOLEAN==cell.getCellType()) {
System.out.print( cell.getBooleanCellValue()+" " );
writer.write("'"+String.valueOf(cell.getBooleanCellValue()+"',"));
}
else
if(HSSFCell.CELL_TYPE_BLANK==cell.getCellType())
System.out.print( "BLANK " );
else
System.out.print("Unknown cell type");
}
writer.write(");"+"\n");
}
} catch ( IOException ex ) {
ex.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
} }
catch (IOException e) {
e.printStackTrace();
}
}
}
}
Wednesday, 21 December 2016
Your World
Your World | |
Without conquering your senses and making them work according to your order and not influence you by making you obey them, you are not even on the first rung of the ladder of spirituality. If you are able to do that, then you can really control your world – not the world but your world. |
Tuesday, 20 December 2016
BSON :
BSON is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDBdatabase.
It is a binary form for representing simple data structures, associative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB.
The name "BSON" is based on the term JSON and stands for "Binary JSON".[2]
It is a binary form for representing simple data structures, associative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB.
The name "BSON" is based on the term JSON and stands for "Binary JSON".[2]
World Change
World Change | |
Spirituality says, trust yourself to change yourself. And if each one of you does it, the world will change like that [snap of the fingers]. |
How to Install Mongo DB
step 1: click the following link to download mongo DB
https://www.mongodb.com/download-center#community
step 2:run the file
step 3:go to command prompt type mongo, it show error
step 4:set the PATH VARIABLE as C:\Program Files\MongoDB\Server\3.4\bin
step 5:again type mongo in command prompt, it will show
"api-ms-win-crt-runtime-l1-1-0-dll is not found"
step 6:go for the following link to solve the above problem
Download the Visual C++ Redistributable
step 7:down load and run the file
step 8:type mongo in cmd prompt now it will show
step 9: create the following folder :
D:\mongo\data\db
step 10:type following in cmd promt
mongod d:\mongo\data\db
step 11:
now ready to use
step 12: run mongod --dbpath d:\mongo\data\db
https://www.mongodb.com/download-center#community
step 2:run the file
step 3:go to command prompt type mongo, it show error
step 4:set the PATH VARIABLE as C:\Program Files\MongoDB\Server\3.4\bin
step 5:again type mongo in command prompt, it will show
"api-ms-win-crt-runtime-l1-1-0-dll is not found"
step 6:go for the following link to solve the above problem
Download the Visual C++ Redistributable
For Windows 64-bit
For Windows 32-bit
http://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe
step 7:down load and run the file
step 8:type mongo in cmd prompt now it will show
step 9: create the following folder :
D:\mongo\data\db
step 10:type following in cmd promt
mongod d:\mongo\data\db
step 11:
now ready to use
step 12: run mongod --dbpath d:\mongo\data\db
Sunday, 18 December 2016
Personal Discipline
Personal Discipline | |
Personal discipline goes a long way in spiritual progress. Personal discipline shows an inner discipline – that you are balanced, that you don’t put your needs before those of others. It shows itself in courtesy: you give way to others, let them sit first. You will let others eat first, don’t rush. |
Thursday, 15 December 2016
Perfection
Perfection | |
If the spiritual side is perfect and the wordly imperfect, I would call it crippled perfection. Man must try to become a perfect human being, not God. We have come here not to spoil God's creation but to retain it in the divine order. |
Wednesday, 14 December 2016
Money
Money | |
It is a hidden dictum of Nature that every soul must live a happy and restful life. If we do otherwise, we are spoiling His world. We are all family people, but we must be moderate in all our dealings, and money is also essential for us everywhere. So it becomes our duty to have it for our maintenance and good living. But love of money for its own sake is a disease and a sort of sordid ambition according to Dunns. |
Writing and Reading Links in excel fetched from website and writing status of link in excel
WRITING IN EXCEL:
package excelExportAndFileIO;
import java.io.IOException;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class Write {
public static void main(String...strings ) throws IOException
{
Write object =new Write();
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get("https://www.thesun.co.uk/");
System.out.println("opening of webpage");
List<WebElement> links=driver.findElements(By.tagName("a"));
System.out.println("feaching links from webpage");
System.out.println("writting links");
String filePath= System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx";
String sheetName="sheet1";
File file = new File(filePath);
FileInputStream inputStream = new FileInputStream(filePath);
Workbook writeWorkbook = new XSSFWorkbook(inputStream);
Sheet sheet = writeWorkbook.getSheet(sheetName);
int rowCount=0;
int columnCount=0;
for(WebElement link:links)
{
Row newRow = sheet.createRow(rowCount++);
Cell cell = newRow.createCell(columnCount);
cell.setCellValue(link.getAttribute("href"));
}
System.out.println("URL-----"+links.size());
FileOutputStream outputStream = new FileOutputStream(file);
writeWorkbook.write(outputStream);
driver.close();
}
}
READING LINKS FROM EXCEL AND OPENING IN BROWSER:
package excelExportAndFileIO;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Read {
public String readExcel(int rowNum,String sheetName) throws IOException{
String filePath = System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx";
FileInputStream inputStream = new FileInputStream(filePath);
Workbook readWorkbook = null;
readWorkbook = new XSSFWorkbook(inputStream);
Sheet readSheet = readWorkbook.getSheet(sheetName);
int rowCount = readSheet.getLastRowNum();
System.out.println("Row Count"+rowCount);
Row row = readSheet.getRow(rowNum);
return getCellData(row);
}
public static String getCellData(Row row){
String value="";
try{
if(row.getCell(0).getCellType()!=Cell.CELL_TYPE_BLANK){
value= row.getCell(0).getStringCellValue();
}
}catch(NullPointerException e){
}
return value;
}
public static void main(String...strings) throws IOException{
Read objExcelFile = new Read();
for(int i=0;i<2;i++){
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get(objExcelFile.readExcel(i,"Sheet1"));
System.out.println(objExcelFile.readExcel(i,"Sheet1"));
}
}
}
VALIDATION OF LINKS IN EXCEL:
package excelExportAndFileIO;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ValidLink {
public static void main(String...strings ) throws IOException{
ValidLink object =new ValidLink();
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get("https://www.thesun.co.uk");
//driver.get("https://www.google.com");
System.out.println("opening of webpage");
List<WebElement> links=driver.findElements(By.tagName("a"));
System.out.println("feaching links from webpage");
System.out.println("writting links");
String filePath= System.getProperty("user.dir")+"\\excel\\linkValid.xlsx";
String sheetName="sheet1";
File file = new File(filePath);
FileInputStream inputStream = new FileInputStream(filePath);
Workbook writeWorkbook = new XSSFWorkbook(inputStream);
Sheet sheet = writeWorkbook.getSheet(sheetName);
int rowCount=0;
int columnCount1=1,columnCount2=2;
for(WebElement link:links)
{
Row newRow = sheet.createRow(rowCount++);
Cell cell = newRow.createCell(columnCount1);
cell.setCellValue(link.getAttribute("href"));
try
{
String linkUrl=link.getAttribute("href");
URL url = new URL(linkUrl);
HttpURLConnection httpURLConnect=(HttpURLConnection)url.openConnection();
httpURLConnect.setConnectTimeout(3000);
httpURLConnect.connect();
newRow.createCell(columnCount2).setCellValue(httpURLConnect.getResponseCode());
if(httpURLConnect.getResponseCode()==200)
{
newRow.createCell(columnCount2).setCellValue(httpURLConnect.getResponseCode());
rowCount++;
System.out.println(linkUrl+" - "+httpURLConnect.getResponseMessage());
}
}
catch (Exception e)
{
}
break;
}
System.out.println("URL-----"+links.size());
FileOutputStream outputStream = new FileOutputStream(file);
writeWorkbook.write(outputStream);
driver.close();
}}
Tuesday, 13 December 2016
Restlessness:
Restlessness: It means impatience, and reaches up to the reality of love. This is about its meaning. Now listen to its definition. Real restlessness is that in which there is no other wave in the heart except that
Monday, 12 December 2016
Remove Impressions
Remove Impressions | |
You can change your own destiny. Remove the impression, and it is gone. |
Sunday, 11 December 2016
Sleep
Sleep | |
A little discipline in how well you can sleep, how deeply you can sleep, determines your daily state of mind throughout the day. Your morning meditation will be fine. You will not be struggling with your consciousness |
Truth is Pure
Truth is Pure | |
To speak a lie you must be so creative, but to speak the truth you must be simple. The truth is pure, coming straight from your heart. God showers such people with so much love. |
Serenity and Purity
Serenity and Purity | |
Serenity once created should not be spoiled. Purity once created should not be spoiled |
Friday, 9 December 2016
reading content from excel and opening ad link in browser
file name:ReadGuru99ExcelFile.java
package excelExportAndFileIO;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ReadGuru99ExcelFile {
// public String urlLink;
public void readExcel(String sheetName) throws IOException{
//Create a object of File class to open xlsx file
String filePath = System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx";
// File file = new File(filePath+"\\"+fileName);
//Create an object of FileInputStream class to read excel file
FileInputStream inputStream = new FileInputStream(filePath);
Workbook guru99Workbook = null;
//Find the file extension by spliting file name in substring and getting only extension name
guru99Workbook = new XSSFWorkbook(inputStream);
//Read sheet inside the workbook by its name
Sheet guru99Sheet = guru99Workbook.getSheet(sheetName);
//Find number of rows in excel file
int rowCount = guru99Sheet.getLastRowNum();
//Create a loop over all the rows of excel file to read it
System.out.println("Row Count"+rowCount);
for (int i = 0; i < rowCount; i++) {
Row row = guru99Sheet.getRow(i);
getCellData(row);}
}
public static String getCellData(Row row){
String value="";
try{
if(row.getCell(0).getCellType()!=Cell.CELL_TYPE_BLANK){
value= row.getCell(0).getStringCellValue();
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get(value);
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN);
driver.findElement(By.linkText("urlLink")).sendKeys(selectLinkOpeninNewTab);
}
}catch(NullPointerException e){
//return "";
}
return value;
}
// System.out.println("Current row--"+i);
/* String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
String baseUrl = getCellData(row);
driver.get(baseUrl);*/
// driver.get(getCellData(google.com));
// String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN);
// System.out.println( getCellData(row));
//urlLink= getCellData(row);
// driver.findElement(By.linkText("urlLink")).sendKeys(selectLinkOpeninNewTab);
//rowCount++;
// System.out.println(rowCount);
//Main function is calling readExcel function to read data from excel file
public static void main(String...strings) throws IOException{
//Create a object of ReadGuru99ExcelFile class
ReadGuru99ExcelFile objExcelFile = new ReadGuru99ExcelFile();
//Prepare the path of excel file
//Call read file method of the class to read data
objExcelFile.readExcel("Sheet1");
}
}
package excelExportAndFileIO;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ReadGuru99ExcelFile {
// public String urlLink;
public void readExcel(String sheetName) throws IOException{
//Create a object of File class to open xlsx file
String filePath = System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx";
// File file = new File(filePath+"\\"+fileName);
//Create an object of FileInputStream class to read excel file
FileInputStream inputStream = new FileInputStream(filePath);
Workbook guru99Workbook = null;
//Find the file extension by spliting file name in substring and getting only extension name
guru99Workbook = new XSSFWorkbook(inputStream);
//Read sheet inside the workbook by its name
Sheet guru99Sheet = guru99Workbook.getSheet(sheetName);
//Find number of rows in excel file
int rowCount = guru99Sheet.getLastRowNum();
//Create a loop over all the rows of excel file to read it
System.out.println("Row Count"+rowCount);
for (int i = 0; i < rowCount; i++) {
Row row = guru99Sheet.getRow(i);
getCellData(row);}
}
public static String getCellData(Row row){
String value="";
try{
if(row.getCell(0).getCellType()!=Cell.CELL_TYPE_BLANK){
value= row.getCell(0).getStringCellValue();
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get(value);
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN);
driver.findElement(By.linkText("urlLink")).sendKeys(selectLinkOpeninNewTab);
}
}catch(NullPointerException e){
//return "";
}
return value;
}
// System.out.println("Current row--"+i);
/* String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
String baseUrl = getCellData(row);
driver.get(baseUrl);*/
// driver.get(getCellData(google.com));
// String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN);
// System.out.println( getCellData(row));
//urlLink= getCellData(row);
// driver.findElement(By.linkText("urlLink")).sendKeys(selectLinkOpeninNewTab);
//rowCount++;
// System.out.println(rowCount);
//Main function is calling readExcel function to read data from excel file
public static void main(String...strings) throws IOException{
//Create a object of ReadGuru99ExcelFile class
ReadGuru99ExcelFile objExcelFile = new ReadGuru99ExcelFile();
//Prepare the path of excel file
//Call read file method of the class to read data
objExcelFile.readExcel("Sheet1");
}
}
Thursday, 8 December 2016
Purity
Purity | |
Be yourself. Be normal. Only then can you be engulfed by purity. |
Wednesday, 7 December 2016
fetching link from webpage and writing in excel file Method 2(best case)
steps:
1.create maven project
2.attach selenium and chrome drivers
3.set dependency in pom file for Apache POI
4.attach one excel file in the project
file name :NewLinkWritter.java
package excelExportAndFileIO;
import java.io.IOException;
//import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class NewLinkWritter {
public static void main(String...strings ) throws IOException{
NewLinkWritter obj=new NewLinkWritter();
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get("http://vishnuyardinichari.blogspot.in/");
System.out.println("opening of webpage");
List<WebElement> links=driver.findElements(By.tagName("a"));
System.out.println("feaching links from webpage");
System.out.println("writting links");
String filePath= System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx";
String sheetName="sheet1";
File file = new File(filePath);
FileInputStream inputStream = new FileInputStream(filePath);
Workbook guru99Workbook = new XSSFWorkbook(inputStream);
Sheet sheet = guru99Workbook.getSheet(sheetName);
int rowCount=0;
int columnCount=0;
for(WebElement link:links)
{
Row newRow = sheet.createRow(rowCount++);
Cell cell = newRow.createCell(columnCount);
cell.setCellValue(link.getAttribute("href"));
}
System.out.println("URL-----"+links.size());
FileOutputStream outputStream = new FileOutputStream(file);
guru99Workbook.write(outputStream);
//guru99Workbook.close();
//guru99Workbook.close();
driver.close();
//sheet1.close();
}}
1.create maven project
2.attach selenium and chrome drivers
3.set dependency in pom file for Apache POI
4.attach one excel file in the project
file name :NewLinkWritter.java
package excelExportAndFileIO;
import java.io.IOException;
//import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class NewLinkWritter {
public static void main(String...strings ) throws IOException{
NewLinkWritter obj=new NewLinkWritter();
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get("http://vishnuyardinichari.blogspot.in/");
System.out.println("opening of webpage");
List<WebElement> links=driver.findElements(By.tagName("a"));
System.out.println("feaching links from webpage");
System.out.println("writting links");
String filePath= System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx";
String sheetName="sheet1";
File file = new File(filePath);
FileInputStream inputStream = new FileInputStream(filePath);
Workbook guru99Workbook = new XSSFWorkbook(inputStream);
Sheet sheet = guru99Workbook.getSheet(sheetName);
int rowCount=0;
int columnCount=0;
for(WebElement link:links)
{
Row newRow = sheet.createRow(rowCount++);
Cell cell = newRow.createCell(columnCount);
cell.setCellValue(link.getAttribute("href"));
}
System.out.println("URL-----"+links.size());
FileOutputStream outputStream = new FileOutputStream(file);
guru99Workbook.write(outputStream);
//guru99Workbook.close();
//guru99Workbook.close();
driver.close();
//sheet1.close();
}}
fetching link from webpage and writing in excel file Method 1(worst case)
steps:
1.create maven project
2.attach selenium and chrome drivers
3.set dependency in pom file for Apache POI
4.attach one excel file in the project
METHOD 1:
file 1: SunWebLink.java
package excelExportAndFileIO;
import java.io.IOException;
//import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class SunWebLink {
public static void main(String...strings) throws IOException{
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get("http://vishnuyardinichari.blogspot.in/");
System.out.println("opening of webpage");
List<WebElement> links=driver.findElements(By.tagName("a"));
System.out.println("feaching links from webpage");
WriteGuru99ExcelFile objExcelFile = new WriteGuru99ExcelFile();
System.out.println("calling write program");
/*
ArrayList<String> data=new ArrayList<String>();
data.add("links");
*/
System.out.println("writting links");
for(WebElement link:links){
// System.out.println(link.getAttribute("href"));
objExcelFile.writeExcel(System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx","sheet1",link.getAttribute("href"));
}
//System.out.println("complete writing links");
System.out.println("URL-----"+links.size());
}
}
1.create maven project
2.attach selenium and chrome drivers
3.set dependency in pom file for Apache POI
4.attach one excel file in the project
METHOD 1:
file 1: SunWebLink.java
package excelExportAndFileIO;
import java.io.IOException;
//import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class SunWebLink {
public static void main(String...strings) throws IOException{
String driverPath=System.getProperty("user.dir")+"/drivers/chromedriver.exe";
System.setProperty("webdriver.chrome.driver",driverPath);
WebDriver driver = new ChromeDriver();
driver.get("http://vishnuyardinichari.blogspot.in/");
System.out.println("opening of webpage");
List<WebElement> links=driver.findElements(By.tagName("a"));
System.out.println("feaching links from webpage");
WriteGuru99ExcelFile objExcelFile = new WriteGuru99ExcelFile();
System.out.println("calling write program");
/*
ArrayList<String> data=new ArrayList<String>();
data.add("links");
*/
System.out.println("writting links");
for(WebElement link:links){
// System.out.println(link.getAttribute("href"));
objExcelFile.writeExcel(System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx","sheet1",link.getAttribute("href"));
}
//System.out.println("complete writing links");
System.out.println("URL-----"+links.size());
}
}
file 2:WriteGuru99ExcelFile.java
package excelExportAndFileIO;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class WriteGuru99ExcelFile {
public void writeExcel(String filePath,String sheetName,String string) throws IOException{
//Create a object of File class to open xlsx file
File file = new File(filePath);
//Create an object of FileInputStream class to read excel file
FileInputStream inputStream = new FileInputStream(filePath);
Workbook guru99Workbook = null;
//Find the file extension by spliting file name in substing and getting only extension name
guru99Workbook = new XSSFWorkbook(inputStream);
//Read excel sheet by sheet name
Sheet sheet = guru99Workbook.getSheet(sheetName);
//Get the current count of rows in excel file
int rowCount = sheet.getLastRowNum()-sheet.getFirstRowNum();
//Get the first row from the sheet
//Row row = sheet.getRow(0);
//Create a new row and append it at last of sheet
Row newRow = sheet.createRow(rowCount+1);
//Create a loop over the cell of newly created Row
for(int j = 0;j<2300; j++){
//Fill data in row
Cell cell = newRow.createCell(j);
//System.out.println("Data to write-"+string);
cell.setCellValue(string);
}
//Close input stream
//Create an object of FileOutputStream class to create write data in excel file
FileOutputStream outputStream = new FileOutputStream(file);
//write data in the excel file
guru99Workbook.write(outputStream);
//close output stream
outputStream.close();
inputStream.close();
}
public static void main(String...strings) throws IOException{
//Create an array with the data in the same order in which you expect to be filled in excel file
String[] valueToWrite = {"Mr. E","Noida"};
//Create an object of current class
WriteGuru99ExcelFile objExcelFile = new WriteGuru99ExcelFile();
//Write the file using file name , sheet name and the data to be filled
// objExcelFile.writeExcel(System.getProperty("user.dir")+"\\excel\\ExportExcel.xlsx","sheet1",valueToWrite);
}
}
RUN:
run the application at java application
Live in the Present
All past, future and present are human creations. Animals don't know of a yesterday or a tomorrow. They live in the present. If we could also live in the present, this present would be eternal; there would be no past, no future – "I am." |
Tuesday, 6 December 2016
basic web page desinging
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>self trail</title>
<style>
/*.WebContainer{
width: 100%;
height: auto;
}*/
/*.articles{
width:90%;
height: auto;
margin: auto;
}*/
/*body, html {
margin: 0px;
padding: 0px;
}*/
.Container {
width: 90%;
min-width: 500px;
margin: auto;
}
header {
width: 100%;
height: 120px;
line-height: 120px;
background-color: pink;
}
header span {
color: #fff;
font-size: 30px;
padding-left: 20px;
}
/*nav {
width: 100%;
height: 40px;
background-color: grey;
}*/
ul.tab {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Float the list items side by side */
ul.tab li {float: left;}
/* Style the links inside the list items */
ul.tab li a {
display: inline-block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s;
font-size: 17px;
}
/* Change background color of links on hover */
ul.tab li a:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
ul.tab li a:focus, .active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
.content {
width: 100%;
height: 700px;
padding: 10px 0px;
background-color: skyblue;
}
footer {
width: 100%;
height: 80px;
background-color: #808080;
margin-bottom: 20px;
}
.main_articles {
width: 70%;
float: left;
height: 650px;
margin-left: 10px;
}
.side_article {
width: 25%;
float: right;
height: 600px;
border-left: 1px dotted #6d6d6d;
}
.siteDescription {
display: -moz-box; /* Firefox*/
display: -webkit-box; /* Chrome */
display: -ms-flexbox; /* IE 10 */
display: flexbox;
flex-direction: row;
flex-align:start;
width: 95%;
height: 150px;
}
/*.desImage {
-webkit-box-ordinal-group: 1; /* iOS 6-, Safari, Opera*/
/* -moz-box-ordinal-group: 1; /* Firefox*/
/*-ms-flex-order: 1; /* IE 10 */
/*-webkit-order: 1; /* Chrome */
/* flex-order: 1;
width: 200px;
height: 150px;
}
.desImage img {
width: 200px;
height: 150px;
margin-left: 5px;
border: 2px solid #6d6d6d;
}
*/
.des {
margin-left: 15px;
-webkit-box-ordinal-group: 2; /* iOS 6-, Safari, Opera*/
-moz-box-ordinal-group: 2; /* Firefox*/
-ms-flex-order: 2; /* IE 10 */
-webkit-order: 2; /* Chrome */
flex-order: 2;
width: 70%;
height: 140px;
background-color: #e9e9e9;
padding: 5px;
}
/*@media all and (max-width: 900px) {
.side_article { /* Hide advertisement panel*/
/*display: none;
visibility: hidden;
}*/
/* .siteDescription {
width: 100%; /* Earlier 70%*/
/* }
/*
.main_articles {
width: 90%;/* Earlier 95%*/
/* }
} */
/*@media all and (max-width: 700px) {
header {
height: 90px; /* Earlier 120px*/
/* line-height: 90px; /* Earlier 120px*/
/* }
header span {
font-size: 20px; /* Earlier 30px*/
/* }
.des {
width: 50%; /* Earlier 70%*/
/* background-color: #e9e9e9;
}
}
@media all and (max-width: 500px) {
header {
height: 70px;
line-height: 70px;
}
header span {
font-size: 16px;
}
.side_article {
display: none;
visibility: hidden;
}
.main_articles {
width: 90%;
}
.siteDescription {
width: 95%;
height: auto;
display: block;
}
.desImage {
margin: auto;
width: 90%;
height: auto;
}
.desImage img {
width: 95%;
margin-left: 5px;
}
.des {
margin: auto;
margin-top: 10px;
width: 90%;
height: 300px;
background-color: #d9d9d9;
}
}*/
body, html {
margin: 0px;
padding: 0px;
background-color: #ededed;
font-family: 'Trebuchet MS';
}
/*
@media only screen and (max-device-width: 480px), only screen and (-webkit-min-device-pixel-ratio: 2) , screen and (-webkit-device-pixel-ratio:1.5){
.Container {
width: 90%;
min-width: 480px;
margin: auto;
}
header {
width: 100%;
height: 150px;
line-height: 150px;
background-color: #313131;
}
header span {
color: #fff;
font-size: 35px;
padding-left: 20px;
}
nav {
width: 100%;
height: 70px;
background-color: #ff6a00;
}
.content {
width: 100%;
height: 900px;
clear:both;
padding: 10px 0px;
background-color: #fff;
font-size:35px;
}
footer {
width: 100%;
height: 80px;
background-color: #808080;
margin-bottom: 20px;
}
.main_articles {
width: 95%;
float: left;
height: auto;
margin:auto;
}
.side_article {
display: none;
visibility: hidden;
}
.siteDescription {
width: 95%;
height: auto;
display: block;
margin:auto;
}
.desImage {
margin: auto;
width: 100%;
height: auto;
}
.desImage img {
width: 100%;
height: 100%;
margin-left: 5px;
border: 2px solid #6d6d6d;
}
.des {
margin: auto;
margin-top: 10px;
width: 100%;
height: 300px;
background-color: #d9d9d9;
padding: 5px;
}
}*/
.ads {
width: 90%;
margin: auto;
margin-top: 10px;
height: 150px;
text-align: center;
padding-top: 10px;
background-color: #e5eff3;
}
</style>
</head>
<body>
<div class="Container">
<header>
<span>yemmy pizza shop </span>
</header>
<nav>
<ul class="tab">
<li><a >Cheese pizza</a></li>
<li><a >Mushroom pizza</a></li>
<li><a >Chiken pizza</a></li>
<li><a >Corn Pizza</a></li>
<li><a >veg Pizza</a></li>
</ul>
</nav>
<div class="content">
<section class="main_articles">
<article class="siteDescription">
<div class="desImage">
<img src="pizza.png" />
</div>
<div class="des">
yemmy pizzzaaa......
</div>
</article>
</section>
<aside class="side_article">
<div class="ads">
pizza 1.
</div>
<div class="ads">
pizza 2.
</div>
</aside>
</div>
<footer>
</footer>
</div>
</body>
</html>
Subscribe to:
Posts (Atom)