import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
使用@Value注解
@Value(value="classpath:default.json")
private Resource resource;
BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()));
StringBuffer message=new StringBuffer();
String line = null;
while((line = br.readLine()) != null) {
message.append(line);
}
String defaultString=message.toString();
String result=defaultString.replace("\r\n", "").replaceAll(" +", "");
System.out.println(result);