本文整理汇总了Java中com.jk.util.JKIOUtil类的典型用法代码示例。如果您正苦于以下问题:Java JKIOUtil类的具体用法?Java JKIOUtil怎么用?Java JKIOUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JKIOUtil类属于com.jk.util包,在下文中一共展示了JKIOUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryLoadConfig
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Try load config.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
protected static void tryLoadConfig() throws IOException {
String configFileName = JKDataSourceFactory.getConfigFileName();
logger.debug("configFileName :", configFileName);
final String configPath = JKContextFactory.getCurrentContext().getConfigPath();
logger.debug("Config path: ", configPath);
final JKResourceLoader resourceLoader = JKResourceLoaderFactory.getResourceLoader();
configFileName = configPath.concat(configFileName);
logger.debug("Full-config filename: ", configFileName);
final InputStream in = resourceLoader.getResourceAsStream(configFileName);
if (in != null) {
logger.debug("Loading exists file :".concat(configFileName));
final Properties prop = JKIOUtil.readPropertiesFile(configFileName);
// prop.load(in);
logger.debug("constructing datasource");
// System.getProperties().putAll(prop);;
defaultResourceManager = JKDataSourceFactory.createInstance(prop);
}
}
示例2: init
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Inits the.
*/
@PostConstruct
// ////////////////////////////////////////////////////
public void init() {
try {
InputStream instream = JKIOUtil.getInputStream("/system.properties");
if (instream != null) {
BufferedReader in = new BufferedReader(new InputStreamReader(instream, "utf8"));
String line;
while ((line = in.readLine()) != null) {
String label[] = line.split("=");
if (label.length >= 2) {
prop.setProperty(label[0], line.substring(line.indexOf("=") + 1));
}
}
}
} catch (IOException e) {
System.err.println("Error while loading Lables : " + e);
e.printStackTrace();
}
}
示例3: requestUrl
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Send http request.
*
* @param url
* the url
* @param method
* the method
* @param header
* the header
* @param body
* the body
* @return the string
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws HttpException
* the http exception
*/
public static String requestUrl(final String url, final String method, final Properties header, final String body) {
try {
final URL siteUrl = new URL(url);
final HttpURLConnection connection = (HttpURLConnection) siteUrl.openConnection();
connection.setRequestMethod(method);
final Enumeration<?> keys = header.keys();
while (keys.hasMoreElements()) {
final String key = (String) keys.nextElement();
connection.addRequestProperty(key, header.getProperty(key));
}
connection.setDoOutput(true);
final OutputStream out = connection.getOutputStream();
out.write(body.getBytes());
connection.connect();
final int errorCode = connection.getResponseCode();
if (errorCode != HttpURLConnection.HTTP_OK) {
throw new JKHttpException(connection.getResponseMessage(), errorCode);
}
final String response = JKIOUtil.convertToString(connection.getInputStream());
return response;
} catch (IOException e) {
throw new JKHttpException(e);
}
}
示例4: getInstance
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Gets the single instance of JKFacesConfigurations.
*
* @return single instance of JKFacesConfigurations
*/
public static JKFacesConfigurations getInstance() {
if (instance == null) {
instance = new JKFacesConfigurations();
instance = JKXmlHandler.getInstance().parse(JKIOUtil.getInputStream(META_INF_JK_FACES_CONFIG_XML), JKFacesConfigurations.class,
JKNamespace.class, JKTagMapping.class);
}
return instance;
}
示例5: JKPoolingDataSource
import com.jk.util.JKIOUtil; //导入依赖的package包/类
public JKPoolingDataSource(String configFileName) {
this(JKIOUtil.readPropertiesFile(configFileName));
}
示例6: getBinaryStream
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Gets the binary stream.
*
* @param rs
* the rs
* @param name
* the name
* @return the binary stream
* @throws SQLException
* the SQL exception
*/
// //////////////////////////////////////////////////////////////////////////////////////
public static byte[] getBinaryStream(final ResultSet rs, final String name) throws SQLException {
final InputStream in = rs.getBinaryStream(name);
if (in == null) {
return null;
}
return JKIOUtil.readStream(in);
}
示例7: MP3Player
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Instantiates a new MP 3 player.
*
* @param filename
* the filename
* @throws FileNotFoundException
* the file not found exception
*/
// constructor that takes the name of an MP3 file
public MP3Player(final String filename) throws FileNotFoundException {
this(JKIOUtil.getInputStream(filename));
this.filename = filename;
}
示例8: downloadFile
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Download file.
*
* @param fileUrl
* the file url
* @param localFile
* the local file
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static void downloadFile(final String fileUrl, final String localFile) throws IOException {
final URL url = new URL(fileUrl);
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
final byte[] data = JKIOUtil.readStream(connection.getInputStream());
JKIOUtil.writeBytesToFile(data, localFile);
}
示例9: runScript
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Run script.
*
* @param fileName
* the file name
*/
@Override
public void runScript(String fileName) {
String query = JKIOUtil.readFile(fileName);
execute(query);
}
示例10: getJdbcDrivers
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Gets the jdbc drivers.
*
* @return the jdbc drivers
*/
public static Properties getJdbcDrivers() {
return JKIOUtil.readPropertiesFile("drivers.properties");
}
示例11: play
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Play.
*
* @param fileName
* the file name
* @throws FileNotFoundException
* the file not found exception
* @throws SoundException
* the sound exception
*/
public static void play(final String fileName) throws FileNotFoundException, SoundException {
final InputStream inputStream = JKIOUtil.getInputStream(fileName);
play(inputStream);
}
示例12: setData
import com.jk.util.JKIOUtil; //导入依赖的package包/类
/**
* Sets the data.
*
* @param in
* the new data
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public void setData(final InputStream in) throws IOException {
final byte[] bytes = JKIOUtil.readStream(in);
setData(bytes);
}