Java Code Examples for jodd.io.FileUtil#appendString()
The following examples show how to use
jodd.io.FileUtil#appendString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapUtil.java From jeecg with Apache License 2.0 | 4 votes |
/** * 修改 * * @return * @throws IOException */ public static boolean modifyInformation(String dn, String employeeID, DirContext dc, String[] employeeArray) throws IOException { try { String[] modifyAttr = { "telephoneNumber" }; // employeeArray.length - 1的目的去除员工编号 ModificationItem[] modifyItems = new ModificationItem[employeeArray.length - 1]; for (int i = 0; i < modifyAttr.length; i++) { String attrName = modifyAttr[i]; Attribute attr = new BasicAttribute(attrName, employeeArray[i + 1]); modifyItems[i] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr); } /* 修改属性 */ // Attribute attr0 = new BasicAttribute("telephoneNumber", // telephoneNumber); // modifyItems[0] = new // ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr0); /* 删除属性 */ // Attribute attr0 = new BasicAttribute("description","陈轶"); // modifyItems[0] = new // ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr0); /* 添加属性 */ // Attribute attr0 = new BasicAttribute("employeeID", employeeID); // modifyItems[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, // attr0); /* 修改属性 */ dc.modifyAttributes(dn, modifyItems); return true; } catch (NamingException e) { e.printStackTrace(); System.err.println("Error: " + e.getMessage()); FileUtil.appendString(errorFile, "Error:" + e.getMessage() + "\n"); return false; } }
Example 2
Source File: LdapUtil.java From jeecg with Apache License 2.0 | 4 votes |
/** * 主函数用于测试 * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { // get AD Context String adAdmin = "OP031793"; String adAdminPassword = "xxxxx"; DirContext dc = getDirContext(adAdmin, adAdminPassword); if (dc == null) { //System.out.println("User or password incorrect!"); return; } /* * 假设address.txt中存在如下信息,一个是员工号,一个是手机号,当然也可以加其他内容进来 * OP036616,13111111111 * OP018479,13122222222 * OP017591,13233333333 * OP032528,13244444444 */ FileInputStream fileInputStream = StreamUtils .getFileInputStream("d:\\address.txt"); String strFile = StreamUtils.InputStreamTOString(fileInputStream); String[] lineContextArray = strFile.split("\r\n"); for (int i = 0; i < lineContextArray.length; i++) { if (lineContextArray[i] == null) continue; String lineContext = lineContextArray[i]; String[] employeeArray = lineContext.split(","); String employeeID = employeeArray[0]; String dn = getDN(ROOT, "", "sAMAccountName=" + employeeID, dc); if (dn == null) { FileUtil.appendString(errorFile, "Not find user:" + employeeID + "\n"); continue; } modifyInformation(dn, employeeID, dc, employeeArray); } close(dc); }