DVM Syntax:
dvm:lookupValue("DVM Location ","Key","ValueName","Value","")
Example :
dvm:lookupValue("oramds:/apps/Hello/dvm/wave3/xyz.dvm","Key","compName","Value","")
Count Line for large file in Java: ( Fast Execution )
/**
* @param filePath
* @return
* @throws FileNotFoundException
* @throws IOException
*/
public int countLineNumbers(String filePath) throws FileNotFoundException,
IOException {
LineNumberReader lnr =
new LineNumberReader(new FileReader(new File(filePath)));
lnr.skip(Long.MAX_VALUE);
int lineCount = lnr.getLineNumber() + 1;
lnr.close();
return lineCount;
}
Move File and Copy File logic in Java:
public void moveWorkingFile(String sourceFile, String destinationPath) {
try {
File afile = new File(sourceFile);
afile.renameTo(new File(destinationPath));
} catch (Exception e) {
throw ex;
}
}
import oracle.j2ee.ws.common.util.FileUtils;
public void copyWorkingFile(String sourceFile,
String destinationPath) throws Exception {
try {
FileUtils.copyFile(new File(sourceFile),
new File(destinationPath));
} catch (Exception ex) {
throw ex;
}
}
StringTokenizer :
private HashMap<String, String> propertiesMap = new HashMap<String, String>();
strProps ( userName=xyz | password = abc | url = http)
private void loadCommonProperties(String strProps) throws Exception {
String strTempProps = "";
try {
StringTokenizer tok = new StringTokenizer(strProps, "|");
while (tok.hasMoreTokens()) {
strTempProps = tok.nextToken();
if (strTempProps.contains("=")) {
String[] strKeyVal = strTempProps.split("=");
if( strKeyVal.length < 2 ){
propertiesMap.put(strKeyVal[0], " ");
}else{
propertiesMap.put(strKeyVal[0], strKeyVal[1]);
}
}
}
} catch (Exception ex) {
throw ex;
}
}
Value get from Map
propertiesMap.get("userName");
Creating Connection in Java code from Data Source JNDI Name:
private Connection getJdbcConnection(String jdbcParams) throws SQLException,
NamingException,
ClassNotFoundException {
try {
String[] strParam = jdbcParams.split(",");
String serverUrl = strParam[0];
String jndi = strParam[1];
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL, serverUrl);
InitialContext ctx = new InitialContext(prop);
DataSource dataSource = (DataSource)ctx.lookup(jndi);
Connection objConn = dataSource.getConnection();
}catch(Exception ex){
throw ex;
}
return objConn;
}
Java code to Convert Unix File format to DOS File Format
Note : Below logic only works in Unix Flavor platform.
public static String convertUnixToDosFile(String sourceFile,String targetFile) {
try {
Runtime.getRuntime().exec("unix2dos " + sourceFile + " " + targetFile);
} catch (IOException e) {
e.printStackTrace();
}
return "true";
}
dvm:lookupValue("DVM Location ","Key","ValueName","Value","")
Example :
dvm:lookupValue("oramds:/apps/Hello/dvm/wave3/xyz.dvm","Key","compName","Value","")
Count Line for large file in Java: ( Fast Execution )
/**
* @param filePath
* @return
* @throws FileNotFoundException
* @throws IOException
*/
public int countLineNumbers(String filePath) throws FileNotFoundException,
IOException {
LineNumberReader lnr =
new LineNumberReader(new FileReader(new File(filePath)));
lnr.skip(Long.MAX_VALUE);
int lineCount = lnr.getLineNumber() + 1;
lnr.close();
return lineCount;
}
Move File and Copy File logic in Java:
public void moveWorkingFile(String sourceFile, String destinationPath) {
try {
File afile = new File(sourceFile);
afile.renameTo(new File(destinationPath));
} catch (Exception e) {
throw ex;
}
}
import oracle.j2ee.ws.common.util.FileUtils;
public void copyWorkingFile(String sourceFile,
String destinationPath) throws Exception {
try {
FileUtils.copyFile(new File(sourceFile),
new File(destinationPath));
} catch (Exception ex) {
throw ex;
}
}
StringTokenizer :
private HashMap<String, String> propertiesMap = new HashMap<String, String>();
strProps ( userName=xyz | password = abc | url = http)
private void loadCommonProperties(String strProps) throws Exception {
String strTempProps = "";
try {
StringTokenizer tok = new StringTokenizer(strProps, "|");
while (tok.hasMoreTokens()) {
strTempProps = tok.nextToken();
if (strTempProps.contains("=")) {
String[] strKeyVal = strTempProps.split("=");
if( strKeyVal.length < 2 ){
propertiesMap.put(strKeyVal[0], " ");
}else{
propertiesMap.put(strKeyVal[0], strKeyVal[1]);
}
}
}
} catch (Exception ex) {
throw ex;
}
}
Value get from Map
propertiesMap.get("userName");
Creating Connection in Java code from Data Source JNDI Name:
private Connection getJdbcConnection(String jdbcParams) throws SQLException,
NamingException,
ClassNotFoundException {
try {
String[] strParam = jdbcParams.split(",");
String serverUrl = strParam[0];
String jndi = strParam[1];
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL, serverUrl);
InitialContext ctx = new InitialContext(prop);
DataSource dataSource = (DataSource)ctx.lookup(jndi);
Connection objConn = dataSource.getConnection();
}catch(Exception ex){
throw ex;
}
return objConn;
}
Java code to Convert Unix File format to DOS File Format
Note : Below logic only works in Unix Flavor platform.
public static String convertUnixToDosFile(String sourceFile,String targetFile) {
try {
Runtime.getRuntime().exec("unix2dos " + sourceFile + " " + targetFile);
} catch (IOException e) {
e.printStackTrace();
}
return "true";
}
No comments:
Post a Comment