First row inserted successfully, when ever second row inserting into excel getting NullPointerException import java.io.FileInputStream; import java.io.FileOutputStream;     import java.io.IOException;     import java.util.List;     import java.util.concurrent.TimeUnit;  import org.apache.poi.ss.usermodel.DataFormatter; 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.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook;  import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select;  public class CityBusRoutes {      static String cityName;     static String routeNo;     static String routeDetails;      static String routeList;      public static void main(String[] args) throws IOException {          // TODO Auto-generated method stub          System.setProperty("webdriver.chrome.driver",                 "D://Selenium//Selenium Drivers//chromedriver_win32//chromedriver.exe");         WebDriver driver = new ChromeDriver();          driver.get("http://www.onefivenine.com/busRoute.dont?method=findBusRoute");          driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);          FileInputStream fis = new FileInputStream("D://City bus routes task//routes-list.xlsx");         XSSFWorkbook wb = new XSSFWorkbook(fis);         XSSFSheet sh = wb.getSheetAt(0);          int totalNoOfRows = sh.getLastRowNum();         System.out.println("Row count :"+totalNoOfRows);          for (int i = 1; i &lt; totalNoOfRows; i++) {              XSSFRow row = sh.getRow(i);             cityName = new DataFormatter().formatCellValue(row.getCell(0));             routeNo = new DataFormatter().formatCellValue(row.getCell(1));              System.out.println("route opened");              Select ddl1 = new Select(driver.findElement(By.id("cityId")));              ddl1.selectByVisibleText(cityName);              Select ddl2 = new Select(driver.findElement(By.xpath(".//*[@id='routeId']")));             ddl2.selectByVisibleText(routeNo);              System.out.println("route selected");              routeDetails=driver.findElement(By.xpath("html/body/table/tbody/tr[3]/td[2]/div[2]/table[2]")).getText();             routeList=driver.findElement(By.xpath("html/body/table/tbody/tr[3]/td[2]/div[2]/table[3]/tbody/tr/td[1]/table")).getText();                  row.getCell(2).setCellValue(routeDetails);                 row.getCell(3).setCellValue(routeList);                  FileOutputStream fos = new FileOutputStream("D://City bus routes task//routes-list.xlsx");                  wb.write(fos);                 fos.close();         }     }    }   Below is my StackTrace:  Row count :2668 route opened route selected route opened route selected Exception in thread "main" java.lang.NullPointerException at CityBusRoutes.main(CityBusRoutes.java:100)   Reading first two cells in first row and writing next two cell in first row, Reading first two cells in second row also happening but writing into second row  is not happening and showing the above error.
What is a NullPointerException, and how do I fix it? What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
How and when should I tell my son that his amazing father isn't his biological father? My son is going on 5 and starting to learn a lot about how we're created. I've been with my husband for 10 years, but nearly 6 years ago I had no other choice but to move 1000 miles away and after trying the long distance thing it didn't work so we split up.   I ended up going through a rough patch and started dating an abusive jerk. After a year I was pregnant. He threatened me trying to force me to have an abortion and I refused. His grandmother was chief of police and he scared me into moving back to Florida.  Eventually, when I was 4 months along in my pregnancy my husband and I picked up right where we left off. He loved me so much and accepted our son as if he was his own and has done an amazing job at raising him.   He enrolled in college while I was pregnant, got us a house and went above and beyond to care for us both (as after giving birth I became very ill due to rare brain and spine conditions). I've always tried to do right by my son. Since day one, even while with my husband, I tried to keep the sperm donor involved. But he wanted no part of his son.  My husband stepped up when the biological father refused. The biological father would pretend that he cared, only to tell me he never cared about him anyway and was just trying to manipulate me into stopping child support (which I did anyway after the first year: I felt it wasn't right to take his money when my son had a dad who loved, supported and wanted him from the beginning).  This is a very long story so I'll try and make it not so much of a novel. The sperm donor has made it very clear he wants nothing ever to do with my son. My husband has been Dad since the moment my son entered this world. I've always planned to tell my son as early as possible. I think now, or in a few years, it won't be as hard on him compared to us telling him when he's a teen and who knows how he'd handle it.   I just don't know what to do. We have an extremely happy loving family. My son adores his dad. We never argue, we have a very happy non-dysfunctional marriage. I just feel we have a very special family. But I refuse to lie to my son. What if we wait and someone else maliciously tells him? Or if, when he's older and finds out, he spirals out of control?  I'm so confused, I just want to do the right thing and desperately need advice. Especially from others who have been through similar circumstances. We're planning on meeting with therapists and I guess child development specialists, if someone could also point me in the right direction for what type of doctor is best suited in this situation.   Also my son is very happy. He has a wonderful life and I feel as if he would do fine, knowing how much he loves his dad and just beginning to really grasp the concept of life. I don't think it would change anything for him, if that makes sense. I've been worrying over this for 5 years and really need some answers! Which expressions can be used to close an email? At the end of written communication like emails and letters, it is customary to use a closing . Which formal and informal expressions can be used to end emails? What does static/dynamic BVH do? In the render properties panel, under the performance rollout there is a setting for static vs. dynamic BVH.  I am simply wondering what this setting does.  From the :     The raytracing acceleration structure used is a bounding volume hierarchy... This code includes spatial splits to make it more competitive with kd-trees.   Unfortunately, though I know quite a bit about cycles, this is totally Greek to me.  I couldn't really find much else useful on the web other than it may have some impact on animations only.  Can anybody explain this better (maybe starting with BVH in general)? Let $n$ is a natural number. Prove that $$\left\lfloor\frac{n}{1}\right\rfloor+\left\lfloor\frac{n}{2}\right\rfloor+....+\left\lfloor\frac{n}{n}\right\rfloor+\left\lfloor{\sqrt{n}}\right\rfloor$$   is even.   I used induction and the inequality $$x-1&lt;\lfloor{x}\rfloor\le{x}$$ to prove it.  Is there any other, nicer way to do it? Is $2^\sqrt{2}$ irrational? Is it transcendental? Why can other users see the files in my home folder? I just added a new, underprivileged "desktop user," and I was surprised to discover that it can see the files in my home folder.  What is the rational for setting up such lax permissions? Do shots fired before the match starts count towards your end-of-game statistics? In Overwatch, there is short countdown for a few minutes before the match begins. During this time, the defending team is allowed to roam the map to set up their defenses, while the attacking team sits in a small lobby until the game starts and the doors open. (Or in KotH-type maps, both teams wait in a lobby.)  While players wait, it's not uncommon for them to fire off random shots, especially since a lot of the environment is destructable (it's entertaining to watch plush onions sail through the air in the arcade).   Do shots fired before the match starts count towards accuracy statistics at the end of the game? I am rebuilding an old server.  Only one of the five old sites need to go live and all five of the old sites point to the same IP address.  Unfortunately any time a request is made for one of the old sites via their own unique domain names they are passed the pages from the one site that I'm trying to make live.  I would just like the old sites to display a 404 instead of the one site that I'm actually trying to make live.  As an example:   Site 1 (192.168.0.1) [www.first.com] Site 2 (192.168.0.1) [www.second.com] Site 3 (192.168.0.1) [www.third.com]   I want to move site 1 live again.  So I turned on apache on the machine with the IP address of 192.168.0.1, with all of site 1's files in the /var/www directory.  When I browse to 192.168.0.1 or www.first.com I correctly see site 1. When I browse to www.second.com and www.third.com I also receive site 1 which is the problem.  Is there a way I can 404 any request which comes in without www.first.com?  Here is my sites-available:  NameVirtualHost *:80  LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common  &lt;Files ~ "^\.ht"&gt;     Order allow,deny     Deny from all     Satisfy All &lt;/Files&gt;  &lt;Directory /&gt;   Order Deny,Allow   Deny from all   Options None   AllowOverride None   Options None &lt;/Directory&gt;  &lt;Directory /var/www&gt;   Order Allow,Deny   Allow from all &lt;/Directory&gt;  &lt;VirtualHost *:80&gt;         ServerName first.com         ServerAlias www.first.com         DocumentRoot /var/www         ErrorLog /var/log/first.com.err         CustomLog /var/log/first.com.log common &lt;/VirtualHost&gt;  &lt;VirtualHost _default_:*&gt;         ServerName unknown         DocumentRoot /var/www_404 &lt;/VirtualHost&gt; Declare variable to hold job name and if job running kill it I’m looking for a single file that does these things in order.   Declare a variable to hold a job name  Run a query to check whether that job declared is currently running Set up an if loop If the job is running, execute the stored procedure that kills it.   My question is to write a query that declare a variable to hold a job name and gives us result the job is still running or not if the job is running execute the stored proc to kill it.  My manager was asking me to listing running jobs and suspended jobs and declare a variable to hold job name and setup an IF loop like if job is running run proc to kill it. Order of a homomorphism of groups Let $f: G \to H$ be a homomorphism of groups. Assume that $a\in G$ and $\operatorname{ord}(a)=n$. Prove that the order of $f(a)$ is a divisor of $n$. I know that if $H$ is a subgroup of $G$, then $$|G|=|H|\cdot|\text{distinct cosets of $H$}|$$ so $|H|$ must be divisor of $|G|$, but I don't understand how to apply that logic to homomorphisms (or if that will even work). Any help is appreciated! Already awarded bounty refunded on question migration? In March 2011 I offered a 500 bounty on one of my StackOverflow questions () and awarded it to Filip de Vos.   This question was later migrated to Database Administrators and has the following messages on it.     migrated to dba.stackexchange.com by Will♦ Dec 28 '11 at 12:25      This   question belongs on our site for database professionals who wish to   improve their database skills and learn from others in the community.   .     deleted Dec 31 '11 at 1:01   I appear to have been   on whereas Filip .  Is this a bug? Definitely doesn't seem fair or correct to me. The question still shows up in both our bounty tabs despite the migration. I would have hoped that the previously awarded bounty reputation points could still be honoured in this situation. How are ETF prices calculated after the market is closed For example:  Because the NASDAQ: DAX is tracking the index INDEXDB: DAX should its trading value be completely flat when the market the markets are open in the US, but closed in Germany? I'm not seeing that artifact in any of the charts I can find. Dirac Delta function inverse Fourier transform We know that the Fourier transform of the Dirac Delta function is defined as $$\int_{-\infty}^{\infty} \delta(t) e^{-i\omega t} dt = 1,$$  and if I were to reconstruct the function back in time domain, the inverse Fourier transform is defined as  $$\delta(t) = \frac{1}{2\pi}\int_{-\infty}^{\infty} e^{i\omega t} d\omega.$$  How do I compute this integral analytically? How can I move all the window controls to the right (or left)? Downloaded Ubuntu tweak and set window controls to the right side. Only some programs follow the rule. Pidgin as an example has window controls on the right. But Chrome, Thunderbird, Geany, still have controls on the left.  How can I move ALL window controls(close/min/max) to the right (or left)? Twin Paradox, calculating spacetime intervals from both perspectives I've very recently started to try to understand special relativity. I'm want to get a decent understanding of the twin paradox. I'll post what I've done so far and highlight what's gone wrong for me.  The situation is that Alice and Bob both begin at point $x_1$ in Alice's coordinate system $(x,t)$ (we have orientated the axis so that y and z will not matter). Bob then instantaneously moves off with velocity $v$ in the positive $x$ direction. Bob's coordinate system is now $(x',t')=(\gamma (x-vt), \gamma (t-v\frac{x}{c^2}))$. In Alice's coordinates, Bob reaches point $x_2$ after having moved distance $d$, then instantly turns around and travels back to Alice at $-v$. I want to show that Alice's space time interval $\Delta s_A^2$ is greater than Bob's $\Delta s_B^2$, as each path's space time interval is proportional to the proper time passed along that path.    According to Alice: $\Delta s_A^2=-c^2\Delta t^2 + \Delta x_A^2$ where $\Delta t=\dfrac{2d}{v}$ and $\Delta x_A=0$ as she didn't move, but the time elapsed is the time it took bob to travel the distance and then come back. Thus $\Delta s_A^2=-\dfrac{4c^2d^2}{v^2}$  Still according to Alice, Bob's $\Delta s_B^2=-c^2\Delta t^2+\Delta x_B^2$, where the change in time is the same, but now bob has moved distance $d$ twice, thus $\Delta x_B=2d$ ($\Delta x$ refers to total distance traveled rather than displacement which is 0 in this case). Now we have $\Delta s_B^2=-\dfrac{4c^2d^2}{v^2}+4d^2$.     The |size| of Bob's spacetime interval now definitely smaller than Alice's, and this would be all OK, except that when I do the calculations in Bob's frame, they don't agree. This is contradictory to the fact that $\Delta s^2$ is conserved under Lorentz transformations.    According to Bob: $\Delta {s'}_A^2=-c^2\Delta t'^2 + \Delta {x'}_A^2$ where $\Delta t'=\dfrac{2d'}{v}$. I'm not sure if I'm right in saying that $v$, the relative velocity of the two frames, is the only velocity upon which both Alice and Bob will agree on, other than the speed of light. Anyway, $d=\gamma d'$ as lengths contract by $\gamma$ i.e. $d'$ is smaller than $d$ by factor $\gamma$. Also, $\Delta {x'}_A=2d'$, so we have $\Delta {s'}_A^2=-\dfrac{4c^2d'^2}{v^2}+4d'^2=-\dfrac{4c^2d^2}{\gamma ^2 v^2}+\dfrac{4d^2}{\gamma ^2}=4d^2\dfrac{v^2-c^2}{\gamma^2 v^2}\neq \Delta s_A^2$  Although I haven't included them here, my calculations for $\Delta {s'}_B^2$ and $\Delta s_B^2$ agree. Sorry for the ultra-long post, but any help would we well appreciated! At the very beginning of SG1, the Goa'uld invade Earth, and then return somehow. How did they manage to return? There was no DHD, and somehow they didn't let it be known where they were going, IE, there was no log of the return. This seems a bit odd to me... Idempotent of closure and other properties How to create a bootable USB stick? I am looking at this:    I need to create a boot disk to test Ubuntu to make sure it will run on a PC (Compaq Mini CQ10-120LA) I was given. I can create the boot disk off of a Mac (in English) or Windows (but Windows is in Spanish and foreign to me).   Questions:     What format do I choose for the USB stick? (I wish the instructions stated this). What is Dash? (Will I know when I run the installer?) Can I do this from a Mac or Windows computer? Or only from Ubuntu? SQLException: Invalid Column Name...? How to Straighten Curved UVs into Straight Belt