private void loadYAMLResource(final File file) {

		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));

			String line = null;
			while ((line = reader.readLine()) != null) {

				// 1. check for comments
				String[] comments = line.split("#", 2);
				String conf = comments[0];

				// 2. get key and value
				if (conf.length() > 0) {
					String[] kv = conf.split(": ", 2);

					// skip line with no valid key-value pair
					if (kv.length == 1) {
						LOG.warn("Error while trying to split key and value in configuration file " + file + ": " + line);
						continue;
					}

					String key = kv[0].trim();
					String value = kv[1].trim();
					
					// sanity check
					if (key.length() == 0 || value.length() == 0) {
						LOG.warn("Error after splitting key and value in configuration file " + file + ": " + line);
						continue;
					}

					LOG.debug("Loading configuration property: " + key + ", " + value);

					this.confData.put(key, value);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				reader.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
private void loadYAMLResource ( final File file ) { BufferedReader reader = null ; try { reader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( file ) ) ) ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { String [ ] comments = line . split ( "#" , 2 ) ; String conf = comments [ 0 ] ; if ( conf . length ( ) > 0 ) { String [ ] kv = conf . split ( ": " , 2 ) ; if ( kv . length == 1 ) { LOG . warn ( "Error while trying to split key and value in configuration file " + file + ": " + line ) ; continue ; } String key = kv [ 0 ] . trim ( ) ; String value = kv [ 1 ] . trim ( ) ; if ( key . length ( ) == 0 || value . length ( ) == 0 ) { LOG . warn ( "Error after splitting key and value in configuration file " + file + ": " + line ) ; continue ; } LOG . debug ( "Loading configuration property: " + key + ", " + value ) ; this . confData . put ( key , value ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { try { reader . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } }
Loads a YAML-file of key-value pairs.
<p>
Colon and whitespace ": " separate key and value (one per line). The hash tag "#" starts a single-line comment.
<p>
Example:

<pre>
jobmanager.rpc.address: localhost # network address for communication with the job manager
jobmanager.rpc.port   : 6123      # network port to connect to for communication with the job manager
taskmanager.rpc.port  : 6122      # network port the task manager expects incoming IPC connections
</pre>
<p>
This does not span the whole YAML specification, but only the *syntax* of simple YAML key-value pairs (see issue
#113 on GitHub). If at any point in time, there is a need to go beyond simple key-value pairs syntax
compatibility will allow to introduce a YAML parser library.

@param file the YAML file to read from
@see <a href="http://www.yaml.org/spec/1.2/spec.html">YAML 1.2 specification</a>
@see <a href="https://github.com/stratosphere/stratosphere/issues/113">Issue #113</a>