Browsing 7239 questions and answers with Jon Skeet

IndexOutOfBoundsException in File array. What could be the issue?

So I have a directory in my local C drive. C:/Search Files/Folder [number]/hello.txt Inside Search Files I have four foldes named: Folder 1 Folder 2 Folder 3 Folder 4 Inside...
Jon Skeet
people
quotationmark

You're never populating your list. I suspect you should actually have: for (File file : files) { XMLMessage message = new XMLMessage(); xmlMessageList.add(message); if (file.isDirectory()) { String fileName =... more 10/14/2015 4:25:54 PM

people

All datetimes stored in utc

I am building a c# calendar application and have stored all the datetimes in Microsoft SQL-Server DateTime2 type. This data type is searchable using operators such as "","=" etc.....
Jon Skeet
people
quotationmark

For repeated events, you definitely need to store the time zone, yes, and I'd store the local date/time. You might also want to store the UTC value of the first occurrence, if that would be useful for comparison purposes. In theory you... more 10/13/2015 8:33:41 PM

people

timezone coversion issue in Intellij IDEA

I am trying to covert timezone from EST to IST in intellij IDEA, SO after conversion I am getting difference of 10 hr 30 min but when I am running same program with eclipse I am...
Jon Skeet
people
quotationmark

I suspect you actually want a time zone for Eastern Time, e.g. America/New_York. After all, Eastern Time wasn't observing EST on September 15 - it was observing EDT (at least, anywhere that observes daylight savings, which most of Eastern... more 10/13/2015 11:46:14 AM

people

C# Compiler Command Line Error

I'm trying to compile my C# file with the command line by executing the csc (file name) command. I don't want to use an IDE because I prefer the command line right now. However...
Jon Skeet
people
quotationmark

However the csc command is not found I believe because the .NET framework is not properly installed. It's far more likely that you just haven't got it in your path. If you've installed Visual Studio, one of the tool shortcuts... more 10/13/2015 2:14:39 AM

people

Effect of Any() on the state of an IEnumerable

suppose i have a code already working that goes like this .... .... foreach(object item in enumerator.GetItems(arg1, arg2....) { } .... .... where getItems is a method of an...
Jon Skeet
people
quotationmark

Often enumerables themselves are effectively stateless - the state comes in the enumerator which is returned by GetEnumerator(). However, if you want to avoid calling GetEnumerator() twice (which could easily give different results each... more 10/12/2015 11:53:52 PM

people

C# method return versus variable in a lambda

So I was fighting some LINQ (entity framework) lambda which I ultimately fixed by storing the result in a variable. Something like: IQueryable<object> DoStuff() { return /*...
Jon Skeet
people
quotationmark

Sure - it's a matter of understanding what happens to the lambda expression. For LINQ to SQL, EF etc, it's converted into an expression tree - basically data that represents the code in the lambda expression. The LINQ provider then has to... more 10/12/2015 7:43:02 AM

people

My JFrame freezes when my Weighing Scale is off

i have a java application and i am developing a scenario if my application would work if my weighing scale is off. But when i turned off my weighing scale my JFrame freezes is...
Jon Skeet
people
quotationmark

Well, it looks like you're doing this in the UI thread. You should basically avoid doing I/O in the UI thread, as it means that while the I/O is waiting, your UI will be unresponsive. Instead, you should either use asynchronous I/O, or... more 10/12/2015 7:29:07 AM

people

System.Drawing.Bitmap Parameter is not valid

I am having this error: parameter is not valid. On this line: System.Drawing.Bitmap("~\\father\\chocolate.png");
Jon Skeet
people
quotationmark

It's very unlikely that "~\\father\\chocolate.png" is a valid filename on its own - I suspect you want to map that from an ASP.NET somewhat-relative filename to a real local filename first. For example: var bitmap = new... more 10/11/2015 1:44:52 PM

people

How to perform unassigned sum with short variable with out converting in to integer in java

My requirement is to perform unassigned sum with short variables in java with out converting in to integer. Please suggest is it possible to perform unassigned sum or not.
Jon Skeet
people
quotationmark

Java doesn't have an addition operator for short values. If you look at JLS 15.18.2 (Additive Operators (+ and -) for Numeric Types) you'll see that one of the first things that happens is: Binary numeric promotion is performed on the... more 10/11/2015 6:49:51 AM

people

Autoboxing/Unboxing while casting Integer to int using 'cast' method

Here is a very simple case: I am trying to cast an Object type to a primitive like this: Object object = Integer.valueOf(1234); int result1 = int.class.cast(object); //throws...
Jon Skeet
people
quotationmark

cast can't really work well for primitives, given that it can't return a value of the actual primitive type, due to generics in Java... so it would end up boxing again anyway. And if you're not assigning straight to an int value, it would... more 10/10/2015 9:41:10 AM

people