在java中本地更改后上载文件

时间:2017-10-11 14:50:48

标签: java arrays

我正在遍历以下位置的属性文件:<div ng-controller="MyCtrl"> <form name="userForm" ng-submit="submitForm(userForm.$valid)" novalidate> <input name="name" ng-model="name" type="text" required > <br> <button type="submit" ng-disabled="userForm.$invalid" >Enviar</button> </form> </div>

"global.properties"

在更改“global.properties”中的特定参数后,我想知道如何将文件上传到同一位置。例如,在这里,我将“propFileName”附加到属性的末尾:product +“。app.product.types”。进行此追加后,如何将文件“global.properties”上传到user.dir

整个代码:

String currentPath = System.getProperty("user.dir");
File appPropDir = new File(currentPath, "properties");
File app_prop_file = new File(appPropDir, "global.properties");

请帮助我完成上述代码中的public static synchronized void updateGlobalPropFile(String product_name, String file_name) throws Exception { // logger.debug("Entry--> // com.manh.ci.eaas.util.TemplateUtil.updateGlobalPropFile"); System.out.println("in updateGlobalPropFile"); String downloadLoc = ""; String mmcType; String vers; String box, userId, password, location, key; int port; port = 22; String currentPath = System.getProperty("user.dir"); File appPropDir = new File(currentPath, "properties"); File app_prop_file = new File(appPropDir, "global.properties"); downloadLoc = app_prop_file.toString(); port = Integer.parseInt(prop.getProperty("ssh_connection_port")); port = 22; String product = product_name; String file = file_name; String propFileName = "file"; String changeKey = product + ".app.product.types"; System.out.println("changeKey>>" + changeKey); // download global.properties instead of using local copy String globalPropFileLoc = downloadLoc; try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(globalPropFileLoc))))) { ArrayList<String> lines = new ArrayList<String>(); String line = ""; String tempLine = ""; while ((line = br.readLine()) != null) { if (line.startsWith(changeKey) && line.contains(changeKey) && (line.substring(0, changeKey.length()).equals(changeKey))) { String strChangeKey = line.substring(changeKey.length() + 1); // System.out.println("strChangeKey>>"+strChangeKey); if (strChangeKey.equalsIgnoreCase("") || strChangeKey.equalsIgnoreCase(" ")) { // chek if value after = is empty for a newly added changekey : don't add comma // for first value tempLine = line + propFileName; } else { tempLine = line + "," + propFileName; } } else { tempLine = line; } lines.add(tempLine); } if (lines.size() != 0) { BufferedWriter out = new BufferedWriter(new FileWriter(new File(globalPropFileLoc))); String finalStr = ""; for (int i = 0; i < lines.size(); i++) { finalStr = finalStr + lines.get(i) + "\n"; } out.write(finalStr); System.out.println("updated global prop file"); out.close(); } uploadFile(); } catch (Exception e) { // logger.debug(e); e.printStackTrace(); throw e; } } 。非常感谢。

1 个答案:

答案 0 :(得分:0)

这应该可以解决问题:

.navbar-brand {
    font-family: "lato" !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 1.9em;
    color: #393939;
}