Saturday, January 5, 2013
Exception StackTrace to String using Java
Writer result = new StringWriter();
PrintWriter printWriter = new PrintWriter(result);
e.printStackTrace(printWriter);
return result.toString();
}
Friday, January 4, 2013
Get InputStream from a given file path using Java
InputStream inputStream = this.getClass().getResourceAsStream(filePath);
if (inputStream == null) {
File file = null;
file = new File(filePath);
try {
inputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
return inputStream;
}
String to InputStream using Java
InputStream inputStream = new ByteArrayInputStream(string.getBytes());
return inputStream;
}
Write InputStream to a given file path using Java
BufferedReader reader = null;
BufferedWriter writer = null;
try {
reader = new BufferedReader(new InputStreamReader(inputStream));
writer = new BufferedWriter(new FileWriter(filePath));
int c;
while ((c = reader.read()) != -1) {
writer.write(c);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (writer != null) {
writer.flush();
writer.close();
}
if (reader != null) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
ResourceBundle to Properties using Java
Set
Properties properties = new Properties();
for (String key : keys) {
properties.put(key, resourceBundle.getString(key));
}
return properties;
}
Clob to String using Java
BufferedReader br = null;
StringBuffer buffer = null;
try {
br = new BufferedReader(clob.getCharacterStream());
int c;
buffer = new StringBuffer();
while ((c = br.read()) != -1) {
buffer.append((char) c);
}
return buffer.toString();
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null)
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return buffer.toString();
}
InputStream to String using Java
BufferedReader br = null;
StringBuffer buffer = null;
try {
br = new BufferedReader(new InputStreamReader(inputStream));
String line = null;
buffer = new StringBuffer();
while ((line = br.readLine()) != null) {
buffer.append(line);
}
return buffer.toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null)
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return buffer.toString();
}
Get all files and folders in FTP location
import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
public class GetAllFTPFiles {
public void getAllFTPFiles(String remoteHostName, String username,
String password, String workingDirectory) {
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(remoteHostName);
ftpClient.login(username, password);
ftpClient.changeWorkingDirectory(workingDirectory);
getFTPFiles(ftpClient, "");
} catch (Throwable e) {
e.printStackTrace();
} finally {
try {
ftpClient.logout();
} catch (Exception e) {
e.printStackTrace();
}
try {
ftpClient.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void getFTPFiles(FTPClient ftpClient, String path)
throws IOException {
FTPFile[] ftpFiles = ftpClient.listFiles(path);
if (ftpFiles == null) {
log("No FTP Files");
} else {
log("No. of FTP Files : " + ftpFiles.length);
}
for (FTPFile ftpFile : ftpFiles) {
if (ftpFile.isDirectory()) {
String newPath = (!path.equals("")) ? path + "/"
+ ftpFile.getName() : ftpFile.getName();
System.out.println(newPath);
getFTPFiles(ftpClient, newPath);
} else {
log(path + "/" + ftpFile.getName());
}
path = path.replaceAll(ftpFile.getName(), "");
}
}
private void log(Object log) {
System.out.println(log);
}
}
Friday, March 25, 2011
Java Ebooks
Java for Everyone, Cay Horstmann Chapter 12 Graphical User Interfaces (2010) (37 Pages)
Composition vs Inheritance Lawrence M. Brown (1 Page)
Introduction to Object Oriented Programming (OOP) by Dr. Lyle N. Long (2008) (13 Pages)
Chapter 10 Deploying Applications and Applets (58 Pages)
Core Java, Volume 1-Fundamentals, Eighth Edition - Chapter 5 Inheritance (2007) (70 Pages)
Concurrent Object-Oriented Programming in JAVA By: Kaoutar El Maghraoui (2003) (14 Pages)
Client-Server Applications in Java by Jasmine J. Ahuja (1997) (37 Pages)
JSF and Struts Classic Reference Manual (2007) (38 Pages)
Java™ Design Patterns: A Tutorial By James W. Cooper (2000) (278 Pages)
Effective Java: Programming Language Guide Joshua Bloch, Addison Wesley (2001) (180 Pages)
Java Collections by John Zukowski, Apress (2001) (295 Pages)
Design Patterns Java™ Workbook By Steven John Metsker, Addison Wesley (2002) (400 Pages)
SCWCD – Study Guide (67 Pages)
Sun Certified Web Component Developer Study Guide - v2 (60 Pages)
Friday, March 4, 2011
Some News on IT Companies In Bhubaneswar
29-Mar-2006 : MindTree logs on to Bhubaneswar
14-Jun-2006 : Creation of IT SEZ
28-Feb-2007 : NEW IT Companies in Bhubaneswar
28-Apr-2007 : Tech Giants Eye Big Plans In Orissa
20-Apr-2008 : BHUBANESWAR - the fastest growing IT hub in India
25-May-2008 : BDA unveils plan for South City
19-Aug-2008 : Bhubaneswar: Catching up with the big boys
05-Jan-2009 : TCS Inaugurates New Development Centre In Bhubaneswar
31_Dec-2009 : Infy pledges allegiance to Orissa with new centre
Wipro Bhubaneswar
23-Dec-2004 : Wipro to set up integrated centre at Bhubaneswar
23-Dec-2004 : Wipro to set up centre in Bhubaneswar
20-July-2006 : Wipro plans more acquisitions
07-May-2007 : Wipro plans training centre in Bhubaneswar
06-Aug-2007 : Wipro to recruit 15,000 at Bhubaneswar
17-Aug-2009: Lack of projects forces Wipro to shift staff from city centre
23-Jul-2010 : Wipro to spend Rs 1 bln on new 3-4 development centres
Friday, February 18, 2011
IE Script Error
Error Message Dialog Title/Message/(Description) -
Internet Explorer Script Error/an error has occurred in the script on this page/
(Line:
Char:
Error:
Code:
URL:
User Action Required : Do you want to continue running scripts on this page
Action Available : Yes and No Button)
Solution :
Internet Options -> Advanced -> Browsing -> "Enable third-party browser extensions" -> Untick -> Restart IE
Desktop got reversed
Google Search
Help1
Help2
Tuesday, February 15, 2011
Wednesday, February 9, 2011
India's Best Companies to Work For – Study 2010
2. Intel Technology India Pvt Ltd.
3. Federal Express Corporation
4. Aviva Life Insurance Co India
Ltd
5. Google India Pvt. Ltd.
6. Qualcomm India Pvt Ltd
7. Marriott Hotels India Pvt. Ltd.
8. American Express
9. Network Appliance Systems
(India) Private Limited (NetApp)
10. NTPC Limted
11. Bharti Airtel Limited
12. Agilent Technologies
13. Classic Stripes Limited
14. ITC Limited - Hotels Division
15. Godrej Consumer Products Ltd.
16. Hilti India Private Limited
17. Corbus India Pvt Ltd
18. Tavant Technologies Pvt. Ltd.
19. MindTree Ltd
20. iNautix Technologies India Pvt
Ltd
21. Sabre Travel Technologies Pvt.
Ltd.
22. Johnson & Johnson Limited
23. Silver Spark Apparels Ltd
24. Titan Industries Limited
25. Mando India Ltd
Accenture Services Pvt Ltd
Acclaris Business Solutions Pvt Ltd
Bajaj Capital Limited
Dr. Reddy's Laboratories Ltd
Ernst & Young Global Shared
Services
Eureka Forbes
Hardcastle Restaurants Pvt. Ltd.
Housing Development Finance
Corporation Limited
Infosys Technologies Ltd
Intelenet Global Services
InterGlobe Enterprises Ltd.
Intuit Technologies Services Pvt Ltd
JM Financial Consultants
Kotak Mahindra Bank Limited
LG Electronics India Pvt Ltd
Marico Limited
Max New York Life Insurance Co.
Ltd
Monsanto India Ltd
PayPal India Private Limited
Quintiles India
Tasty Bite Eatables Limited
Tata Consultancy Services Ltd. -
BPO
The Oberoi Group
ValueLabs
Visakhapatnam Steel Plant,
Rashtriya Ispat Nigam Limited
Source
10 best companies to work for in India
- MakeMyTrip India
- Intel
- Marriott
- NetApp
- American Express Company
- NTPC
- PayPal
- Ajuba
- SAS Institute India