Предполагая, что вы пытаетесь создать файл .properties программно, вы можете сделать это таким образом. Я добавил раздел о том, как добавить что-то в строку сурка. Это довольно простая Java-манипуляция!
public class WritePropertiesFile {
public static void main(String[] args) {
String customString = " are great!";
try {
Properties properties = new Properties();
properties.setProperty("favoriteAnimal", "marmot" + customString);
properties.setProperty("favoriteContinent", "Antarctica");
properties.setProperty("favoritePerson", "Nicole");
File file = new File("test2.properties");
FileOutputStream fileOut = new FileOutputStream(file);
properties.store(fileOut, "Favorite Things");
fileOut.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
, которые будут выводить
#Favorite Things
#Sat Feb 24 00:10:53 PST 2007
favoriteContinent=Antarctica
favoriteAnimal=marmot are great!
favoritePerson=Nicole
Вы пытаетесь создать файл .properties в Java-коде? – Jazzepi
Я уже создал его, но я не знаю, возможно ли, что я написал @Jazzepi – django
Вы можете писать все, что хотите в файл, используя обычные Java-операции; неясно, в чем проблема. –