Skip to main content

Posts

Showing posts from February, 2012

Working with Excel - Reading data

package excelrunner; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /**  *  * @author nurhak.kaya  */ public class ExcelRunner {     public static void main(String[] args) throws IOException {         String fileName = "data.xlsx";         List sheetData = new ArrayList();         FileInputStream fis = null;         try {             fis = new FileInputStream(fileName);             XSSFWorkbook workbook = new XSSFWorkbook(fis);             XSSFSheet sheet = workbook.getSheetAt(0);             Iterator rows = sheet.rowIterator();             while (rows.hasNext()) {                 XSSFRow row = (XSSFRow) rows.next();                 Iterator cells = row.cellIterator

Finding a specific information in a log file

package imeifinder; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; /**  *  * @author nurhak.kaya  */ public class IMEIFinder {     public static void main(String[] args) {         try {             FileInputStream fis = new FileInputStream(                     "2011-11-15_runtime.log");             DataInputStream dis = new DataInputStream(fis);             BufferedReader br = new BufferedReader(new InputStreamReader(dis));             String strLine;             ArrayList list = new ArrayList();                       while ((strLine = br.readLine()) != null) {                 if (strLine.contains("<faultstring>An object referred to was not found")) {                     try {                         String s = strLine.substring(strLine.indexOf('(', 0)                                 + 1, strLine.indexOf(')',