Reading a resource file from within jar

I would like to read a resource from within my jar like so: File file; file = new File(getClass().getResource(“/file.txt”).toURI()); BufferedReader reader = new BufferedReader(new FileReader(file)); //Read the file and it works fine when running it in Eclipse, but if I export it to a jar, and then run it, there is an IllegalArgumentException: Exception in … Read more

What’s the difference between StaticResource and DynamicResource in WPF?

When using resources such as brushes, templates and styles in WPF, they can be specified either as StaticResources <Rectangle Fill=”{StaticResource MyBrush}” /> or as a DynamicResource <ItemsControl ItemTemplate=”{DynamicResource MyItemTemplate}” /> Most of the times (always?), only one works and the other will throw exception during runtime. But I’d like to know why: What is the … Read more

Should a RESTful ‘PUT’ operation return something….

I was wondering what people’s opinions are of a RESTful PUT operation that returns nothing (null) in the response body. 12 s 12 The HTTP specification (RFC 2616) has a number of recommendations that are applicable. Here is my interpretation: HTTP status code 200 OK for a successful PUT of an update to an existing … Read more

Android: How do I get string from resources using its name?

I would like to have 2 languages for the UI and separate string values for them in my resource file res\values\strings.xml: <string name=”tab_Books_en”>Books</string> <string name=”tab_Quotes_en”>Quotes</string> <string name=”tab_Questions_en”>Questions</string> <string name=”tab_Notes_en”>Notes</string> <string name=”tab_Bookmarks_en”>Bookmarks</string> <string name=”tab_Books_ru”>Книги</string> <string name=”tab_Quotes_ru”>Цитаты</string> <string name=”tab_Questions_ru”>Вопросы</string> <string name=”tab_Notes_ru”>Заметки</string> <string name=”tab_Bookmarks_ru”>Закладки</string> Now I need to retrieve these values dynamically in my app: spec.setContent(R.id.tabPage1); String pack … Read more

Should I use Singular or Plural name convention for REST resources?

I’m new to REST and I’ve observed that in some RESTful services they use different resource URI for update/get/delete and Create. Such as Create – using /resources with POST method (observe plural) at some places using /resource (singular) Update – using /resource/123 with PUT method Get – Using /resource/123 with GET method I’m little bit … Read more

What is the single most influential book every programmer should read? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for … Read more

Resource leak: ‘in’ is never closed

Why does Eclipse give me the warming “Resource leak: ‘in’ is never closed” in the following code? public void readShapeData() { Scanner in = new Scanner(System.in); System.out.println(“Enter the width of the Rectangle: “); width = in.nextDouble(); System.out.println(“Enter the height of the Rectangle: “); height = in.nextDouble();