公司用到了rackspace的cloudserver 做為壓力測試的服務器
但是遇到一個問題就是
既然是java的應用就用java來實現吧
package util
import java
import java
import java
import java
import java
import java
import java
import java
import java
import java
public class ModifyPropertiesFile{
public String propertyFilePath=
public String stagingIp=
public String messageIp=
public void modifyPropertiesFile()
{
try {
Properties p = new Properties();
File f = new File(propertyFilePath);
List<String> list = new ArrayList<String>();
list
list
if(f
{
FileInputStream fis;
fis = new FileInputStream(f);
p
p
p
p
p
p
p
p
p
FileOutputStream oFile = new FileOutputStream(f);
p
fis
oFile
}
}
catch (Exception e)
{
e
e
System
}
}
public static void main(String args[])
{
ModifyPropertiesFile t=new ModifyPropertiesFile();
t
}
}
package util
import java
import java
import java
import java
import java
import java
import java
import java
import org
import org
import org
import org
import org
import org
import org
import org
import org
import org
import org
import java
import java
public class ModifyHibernateXml{
private String dataBaseInfo;
private String userName;
private String userPass;
private String deploymentTitle;
private String c
private String fileName;
//defind propertis file name
public String propertyFilePath=
public void modifyXml()
{
try
{
Properties p = new Properties();
HashMap<String
map
File f = new File(map
// load properties value from properties file
if(f
{
FileInputStream fis;
fis = new FileInputStream(f);
p
dataBaseInfo =p
userName =p
userPass =p
deploymentTitle=p
c
fileName =p
fis
}
SAXBuilder builder = new SAXBuilder();
Document doc = builder
Element root = doc
XMLOutputter xmlOutputer = new XMLOutputter();
builder
builder
public InputSource resolveEntity(String publicId
String systemId) throws SAXException
return new InputSource(
d
}
});
// use XPath search your need node
List list = XPath
for(int i =
{
Element disk_element = (Element) list
String name= disk_element
if (name
{
System
disk_element
}
else if (name
{
System
disk_element
}
else if (name
{
System
disk_element
}
else if (name
{
System
disk_element
}
}
// If you want to take out blank line you can uncomment format commect
// Format format = Format
// format
// xmlOutputer
xmlOutputer
}catch (Exception e)
{
e
e
System
}
}
public static void main(String[] args)
{
ModifyHibernateXml hibernate =new ModifyHibernateXml();
hibernate
}
}
package util
public class CloudServer
{
public static void main(String args[])
{
ModifyPropertiesFile t=new ModifyPropertiesFile();
t
ModifyHibernateXml hibernate =new ModifyHibernateXml();
hibernate
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26690.html