简体   繁体   中英

Java - Error while trying to get some Properties

Well, I never thought I would ever need to get this far when programming, but I'm stuck..

I'm building some sort of engine for something I need to build, and I'm getting an "Expected" error..

It drives me crazy since all the source is correct (at least i think so).

Source:

import java.util.*;
import java.io.*;

public class Configurations {

    // Storing the file locations in Strings.
    public static String MOVE_FILE = "./configs/movement.properties";


    // Creating the needed variables for working-out stuff.
    public static String HELLO_WORLD;


    // Reading certain properties file and getting parameters.
    Properties Props = new Properties(); // Asks me to put { { here..
    try {
        Props.load(new FileInputStream(MOVE_FILE));
        HELLO_WORLD = Props.getProperty("MSG", "HelloWorld");
    } catch (IOException e) {
        System.out.println(e);
    }

} // tells me to put }; } here..

Put statements in method body or static block.

public void methodName()
{
  Properties Props = new Properties();
    try {
        Props.load(new FileInputStream(MOVE_FILE));
        HELLO_WORLD = Props.getProperty("MSG", "HelloWorld");
        System.out.println(HELLO_WORLD);
    } catch (IOException e) {
        System.out.println(e);
    }
}

Or

  static
   {
    ...
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM