Skip to content

.class vs .java

What’s the difference between a .class file and a .java file? I am trying to get my applet to work but currently I can only run it in Eclipse, I can’t yet embed in HTML. Thanks **Edit: How to compile …

Initialization of an ArrayList in one line

I wanted to create a list of options for testing purposes. At first, I did this: ArrayList places = new ArrayList(); places.add(“Buenos Aires”); places.add(“C√≥rdoba”); …

How do I use optional parameters in Java?

What specification supports optional parameters? Answer There are several ways to simulate optional parameters in Java: Method overloading. void foo(String a, Integer b) { //… } void foo(String a) { foo(a, 0); // here, 0 is a default value for b } foo(“a”, 2); foo(“a”); One of the limitations of this approach is that it doesn’t work if you have

Java Large Files Disk IO Performance

I have two (2GB each) files on my harddisk and want to compare them with each other: Copying the original files with Windows explorer takes approx. 2-4 minutes (that is reading and writing – on the same physical and logical disk). Reading with twice and comparing the byte arrays on a byte per byte basis takes 20+ minutes.

Is it possible to disable jsessionid in tomcat servlet?

Is it possible to turnoff jsessionid in the url in tomcat? the jsessionid seems not too search engine friendly. Answer You can disable for just search engines using this filter, but I’d advise using it for all responses as it’s worse than just search engine unfriendly. It exposes the session ID which can be used for certain security exploits (more

How do I access a config file inside the jar?

I’m using FlatPack to parse and load data from flat files. This requires loading a config file that stores mappings of the columns of the flat file. I have a constant to define the location of the mapping file: I have a parse(File dataFile) method that actually does the parsing: When I jar up everything and run it as a