Monday, September 3, 2012
Read .xls file in JAVA using POI API
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 java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Iterator;
public class ReadExcelFileUsingPOI {
public static void main(String[] args) throws Exception {
String filename = "D:\\test.xls";
FileInputStream fis = null;
try {
fis = new FileInputStream(filename);
HSSFWorkbook workbook = new HSSFWorkbook(fis);
HSSFSheet sheet = workbook.getSheetAt(0);
Iterator rows = sheet.rowIterator();
while (rows.hasNext()) {
HSSFRow row = (HSSFRow) rows.next();
Iterator cells = row.cellIterator();
while (cells.hasNext()) {
HSSFCell cell = (HSSFCell) cells.next();
int type = cell.getCellType();
if (type == HSSFCell.CELL_TYPE_STRING) {
System.out.println("[" + cell.getRowIndex() + ", "+ cell.getColumnIndex()+"] = STRING;
Value = " + cell.getRichStringCellValue().toString());
} else if (type == HSSFCell.CELL_TYPE_NUMERIC) {
System.out.println("[" + cell.getRowIndex() + ", "+ cell.getColumnIndex()+"]=NUMERIC;
Value = " + cell.getNumericCellValue());
} else if (type == HSSFCell.CELL_TYPE_BOOLEAN) {
System.out.println("[" + cell.getRowIndex() + ", "+ cell.getColumnIndex()+"]=BOOLEAN;
Value = "+ cell.getBooleanCellValue());
} else if (type == HSSFCell.CELL_TYPE_BLANK) {
System.out.println("[" + cell.getRowIndex() +", "+cell.getColumnIndex()+"]=BLANK CELL");
}
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (fis != null) {
fis.close();
}
}
}
}
Java, J2EE, Struts, Hibernate, Web Services, JSF
Apache POI examples,
Create excel file using POI,
Example to read excel file using POI,
Java code read xls file using POI,
POI Examples,
Read excel file in Java,
read MS excel using Java
Sunday, September 2, 2012
Percentage calculation Example in Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public final class Percent {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the total no.of sub");
int n = Integer.parseInt(br.readLine());
int marks[] = new int[n];
int i, tot = 0;
for (i = 0; i < n; i++) {
System.out.println("enter ur marks");
marks[i] = Integer.parseInt(br.readLine());
tot = tot + marks[i];
}
System.out.println("total marks: " + tot);
System.out.println("percentage of marks: " + (float) tot / n);
}
}
Java, J2EE, Struts, Hibernate, Web Services, JSF
How to calcualte Percentage in Java,
Java,
Java examples,
Logic to calculate percentage in java,
Read data from Java console
Thursday, August 30, 2012
Create Excel File in Java using POI API
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class CreateExcelFile {
public static final String FILE_NAME = "D:\\test.xls";
public void createExcelFile(String filename) {
try {
HSSFWorkbook hwb = new HSSFWorkbook();
HSSFSheet sheet = hwb.createSheet("Sheet1");
HSSFRow rowhead = sheet.createRow((short) 0);
rowhead.createCell((short) 0).setCellValue("S.No.");
rowhead.createCell((short) 1).setCellValue("Emp ID");
rowhead.createCell((short) 2).setCellValue("EMP Name");
rowhead.createCell((short) 3).setCellValue("Dept");
rowhead = sheet.createRow((short) 1);
rowhead.createCell((short) 0).setCellValue("1");
rowhead.createCell((short) 1).setCellValue("EMP1");
rowhead.createCell((short) 2).setCellValue("Mallik");
rowhead.createCell((short) 3).setCellValue("Java");
FileOutputStream fileOut = new FileOutputStream(filename);
hwb.write(fileOut);
fileOut.close();
System.out.println("Your excel file has been generated!");
} catch (Exception ex) {
System.out.println(ex);
ex.printStackTrace();
}
}
public static void main(String[] args) {
CreateExcelFile excelFile = new CreateExcelFile();
excelFile.createExcelFile(FILE_NAME);
}
}
Java, J2EE, Struts, Hibernate, Web Services, JSF
Create excel file using POI,
Excel file creation in Java,
How to create excel file in Java using POI,
Java code to create excel file using POI,
POI Examples,
xls file generation in JAVA using POI
Thursday, July 26, 2012
Get Answers for mathematical equations from Google Search
Every one know that Google is always coming up with the new inventions and trying to make the Google as life to the user in future. Below is one of the new invention from the Google.
Google has just released a new 34-button scientific calculator in the Google serch options. Go ahead and enter an equation into Google Search. Try 2+2. Now, instead of simply coming up with the answer, Google presents you with a full, 34-button scientific calculator. You can also find the answers for Trigonometric functions and 'Pi' functions
You can also access the calculator with Desktop Voice Search. Just click the little microphone icon in the search bar, speak your equation out loud and wait a split second for your answer. A pared-down version of the calculator also appears during mobile searches.
Today I have tested the calculator with the mathematical equations, triganometric functions and others..., it is amazing for me.
So, why to wait? start searching mathematical equations or mathematical functions in google.... Hope you will enjoy
Google has just released a new 34-button scientific calculator in the Google serch options. Go ahead and enter an equation into Google Search. Try 2+2. Now, instead of simply coming up with the answer, Google presents you with a full, 34-button scientific calculator. You can also find the answers for Trigonometric functions and 'Pi' functions
You can also access the calculator with Desktop Voice Search. Just click the little microphone icon in the search bar, speak your equation out loud and wait a split second for your answer. A pared-down version of the calculator also appears during mobile searches.
Today I have tested the calculator with the mathematical equations, triganometric functions and others..., it is amazing for me.
So, why to wait? start searching mathematical equations or mathematical functions in google.... Hope you will enjoy
Java, J2EE, Struts, Hibernate, Web Services, JSF
Google,
Google Calculator
Tuesday, July 24, 2012
Are you waiting for Windows 8 to use?
If you are eagerly waiting for new versions of windows with more features, this is the time to know about the windows 8. Every one knows that Microsoft gave a wonderful OS with Windows 7, but still people want more comfort level in using the Computers than earlier.
Microsoft has released a new version of Windows called Windows 8 with excellent features and functionalities. You can upgrade to new version of Windows or you can also purchase as a DVD copy from the stores and pricing will be different for different cases.
Most of the information you can find @ http://www.techgig.com/tech-news/editors-pick/How-can-you-get-Windows-8--13912
Java, J2EE, Struts, Hibernate, Web Services, JSF
upgrade to windows 8,
windows,
Windows 8,
windows 8 upgrade
Friday, July 20, 2012
Convert charr array to String in Java
1. We can convert char array to String by passing the array to String constructor.
public void convertCharArrayToStringOption1() { char[] charArray = new char[] { 'a', 'b', 'c', 'd' }; System.out.println("The new String Array is : "+new String(charArray));}
2. We can also pass the char array to 'valueOf()' static method of String class:
public void convertCharArrayToStringOption1() { char[] charArray = new char[] { 'a', 'b', 'c', 'd' }; System.out.println("The new String Array is : "+ String.valueOf(charArray));}
Java, J2EE, Struts, Hibernate, Web Services, JSF
Convert charr array to String in Java,
Java,
Java Variable conversions
Funtab Fit tablet launched at Rs 5,999
Delhi-based Go Tech has launched a health-oriented tablet called Funtab Fit at a price of Rs 5,999. This device comes with a host of pre-installed health-related apps, along with access for 1,500 books and 7,500 videos for students.
On the specifications front, Funtab Fit has a 7-inch display panel with 800x480 resolution, 1GHz processor, 512MB RAM, 32GB expandable memory, VGA camera and runs onAndroid v4.0.3 (Ice Cream Sandwich). The tablet with a 5-point capacitive touchscreen supports 1080p video playback and various audio and video formats.
It ensures continuous internet connectivity through Wi-Fi and 3G (via USB dongle). The tablet features USB-on-the-go support and can be used to read Word, Excel, PowerPoint, PDF and TXT files. Other notable features of Funtab Fit include multiple language support, 3D games and video output via HDMI cable. The tablet with a 3600mAh battery claims 8-hour battery life.
On the specifications front, Funtab Fit has a 7-inch display panel with 800x480 resolution, 1GHz processor, 512MB RAM, 32GB expandable memory, VGA camera and runs onAndroid v4.0.3 (Ice Cream Sandwich). The tablet with a 5-point capacitive touchscreen supports 1080p video playback and various audio and video formats.
It ensures continuous internet connectivity through Wi-Fi and 3G (via USB dongle). The tablet features USB-on-the-go support and can be used to read Word, Excel, PowerPoint, PDF and TXT files. Other notable features of Funtab Fit include multiple language support, 3D games and video output via HDMI cable. The tablet with a 3600mAh battery claims 8-hour battery life.
Thursday, July 19, 2012
Marker or Tag interface in java
An interface is called a marker interface when it is provided as a handle by java interpreter to mark a class so that it can provide special behaviour to it at runtime and they do not have any method declarations.
Java Marker Interface Examples
- java.lang.Cloneable
- java.io.Serializable
- java.util.EventListener
Why we need Marker Interface?
Suppose you want to persist (save) the state of an object then you have to implement the Serializable interface otherwise the compiler will throw an error. To make more clearly understand the concept of marker interface you should go through one more example.
Suppose the interface Clonable is neither implemented by a class named Myclass nor it’s any super class, then a call to the method clone() on Myclass’s object will give an error. This means, to add this functionality one should implement the Clonable interface. While the Clonable is an empty interface but it provides an important functionality.
We cannot create marker interfaces, as you cannot instruct JVM to add special behavior to all classes implementing (directly) that special interface.
From java 1.5, the need for marker interface is eliminated by the introduction of the java annotation feature. So, it is wise to use java annotations than the marker interface. It has more feature and advantages than the java marker interface.
Java, J2EE, Struts, Hibernate, Web Services, JSF
interface in java,
Java,
Marker interface in java,
tag interface in java
Wednesday, May 2, 2012
Do you know about Privite Browsing in Internet Exporer?
What is InPrivate Browsing?
InPrivate Browsing prevents Internet Explorer from storing data
about your browsing session. This helps prevent anyone else who might be using
your computer from seeing where you visited and what you looked at on the web.
When you start InPrivate Browsing, Internet Explorer opens a new window. The
protection that InPrivate Browsing provides is only in effect during the time
that you use that window. You can open as many tabs as you want in that window,
and they will all be protected by InPrivate Browsing. However, if you open
another browser window, that window will not be protected by InPrivate Browsing.
To end your InPrivate Browsing session, close the browser window.
How do I turn on InPrivate Browsing?
To turn on InPrivate Browsing, do any of the following:
-
Click the Safety button, and then click InPrivate Browsing.
-
Open a new tab, and then, on the new tab page, click Open an InPrivate Browsing window.
-
Press Ctrl+Shift+P.
What is InPrivate Filtering?
InPrivate Filtering helps prevent website content providers from
collecting information about sites you visit. Here's how it works.
Many webpages use content—such as advertisements, maps, or web
analysis tools—from websites other than the one you are visiting. These websites
are called content providers or third-party websites.
When you visit a website with third-party content, some information about you is
sent to the content provider. If a content provider offers content to a large
number of the websites you visit, the content provider could develop a profile
of your browsing preferences. Profiles of browsing preferences can be used in a
variety of ways, including for analysis and serving targeted advertisements.
Usually this third-party content is displayed seamlessly, such as
in an embedded video or image. The content appears to originate from the website
you originally went to, so you may not know that another website might be able
to see where you are surfing. Web analysis or web measurement tools report
website visitors' browsing habits, and are not always obvious to you. While
these tools can sometimes appear as visible content (such as a visitor counter,
for example), they are often not visible to users, as is often the case with web
beacons. Web beacons are typically single-pixel transparent images whose sole
purpose is to track website usage, and they do not appear as visible
content.
InPrivate Filtering works by analyzing web content on the webpages
you visit, and if it sees the same content being used on a number of websites,
it will give you the option to allow or block that content. You can also choose
to have InPrivate Filtering automatically block any content provider or
third-party website it detects, or you can choose to turn off InPrivate
Filtering.
How do I turn InPrivate Filtering on and off?
By default, InPrivate Filtering analyzes the websites you visit
and the content providers they use, but does not automatically block them. You
can choose to allow or block any content provider that InPrivate Filtering
identifies as receiving information about your browsing. Alternatively, you can
have InPrivate Filtering automatically block any content provider, or you can
turn off InPrivate Filtering.
To turn on InPrivate Filtering for the first time, follow these
steps:
-
Click the Safety button, click InPrivate Filtering, and then do one of the following:
-
Click Block for me to block websites automatically.
-
Click Let me choose which providers receive my information to choose content to block or allow. When you're finished, click OK.
-
If you've already turned on InPrivate Filtering, follow these
steps:
-
Open Internet Explorer.
-
Click the Safety button, and then click InPrivate Filtering Settings.
-
Do one of the following:
-
To automatically block websites, click Automatically block.
-
To manually block websites, click Choose content to block or allow.
-
To turn off InPrivate Filtering, click Off.
-
-
Click OK.
How do I manually choose content to block or allow?
To manually block or allow content provider or third-party
websites that could be in the position to know which websites you've visited,
follow these steps:
-
Click the Safety button, and then click InPrivate Filtering Settings.
-
Click Choose content to block or allow, click one or more websites, and then click Allow or Block.
-
To set the number of websites you visit that share content before they are put in the list, type a new number in the Show content from providers used by this number of websites you’ve visited box. You can set the number from 3 to 30.The default setting is 10, which means at least 10 different websites must share the same content provider before it is displayed and you can block or allow it.
-
When you're finished, click OK.
Java, J2EE, Struts, Hibernate, Web Services, JSF
IE Private Browsing,
Private Browsing in IE
Thursday, April 26, 2012
Have you heard about Google Drive?
Mid of this week Google has introduced Google Drive—a place where you can create, share, collaborate, and keep all of your stuff. Whether you’re working with a friend on a joint research project, planning a wedding with your fiancĂ© or tracking a budget with roommates, you can do it in Drive. You can upload and access all of your files, including videos, photos, Google Docs, PDFs and beyond.
With Google Drive, you can:
Drive is built to work seamlessly with your overall Google experience. You can attach photos from Drive to posts in Google+, and soon you’ll be able to attach stuff from Drive directly to emails in Gmail. Drive is also an open platform, so we’re working with many third-party developers so you can do things like send faxes, edit videos andcreate website mockups directly from Drive. To install these apps, visit the Chrome Web Store—and look out for even more useful apps in the future.
Taken from : http://googleblog.blogspot.in/2012/04/introducing-google-drive-yes-really.html
For More info about Google Drive: https://drive.google.com/start?authuser=0#features
With Google Drive, you can:
- Create and collaborate. Google Docs is built right into Google Drive, so you can work with others in real time on documents, spreadsheets and presentations. Once you choose to share content with others, you can add and reply to comments on anything (PDF, image, video file, etc.) and receive notifications when other people comment on shared items.
- Store everything safely and access it anywhere (especially while on the go). All your stuff is just... there. You can access your stuff from anywhere—on the web, in your home, at the office, while running errands and from all of your devices. You can install Drive on your Mac or PC and can download the Drive app to your Android phone or tablet. We’re also working hard on a Drive app for your iOS devices. And regardless of platform, blind users can access Drive with a screen reader.
- Search everything. Search by keyword and filter by file type, owner and more. Drive can even recognize text in scanned documents using Optical Character Recognition (OCR) technology. Let’s say you upload a scanned image of an old newspaper clipping. You can search for a word from the text of the actual article. We also use image recognition so that if you drag and drop photos from your Grand Canyon trip into Drive, you can later search for [grand canyon] and photos of its gorges should pop up. This technology is still in its early stages, and we expect it to get better over time.
Drive is built to work seamlessly with your overall Google experience. You can attach photos from Drive to posts in Google+, and soon you’ll be able to attach stuff from Drive directly to emails in Gmail. Drive is also an open platform, so we’re working with many third-party developers so you can do things like send faxes, edit videos andcreate website mockups directly from Drive. To install these apps, visit the Chrome Web Store—and look out for even more useful apps in the future.
Taken from : http://googleblog.blogspot.in/2012/04/introducing-google-drive-yes-really.html
For More info about Google Drive: https://drive.google.com/start?authuser=0#features
Subscribe to:
Posts (Atom)

.jpg)