Showing posts with label java tips. Show all posts
Showing posts with label java tips. Show all posts

Friday, 25 February 2011

Check for empty lines in java

while((sLine= readerBuf.readLine()) != null)
if (sLine.trim().length() == 0)continue;

Tuesday, 30 November 2010

Java Regex...

Parsing Using Java Regex:

import java.util.regex.*;

public class SampleRegex
{
public static void main(String[] params)
{
Pattern pattern = Pattern.compile("(.*):(.*)");
Matcher matcher = pattern.matcher(params[0]);
if(matcher.matches())
{
System.out.print("Key:");
System.out.println(matcher.group(1));
System.out.print("Value:");
System.out.println(matcher.group(2));
}
else
System.out.print("No match");
}
}

Further reading links:
1. http://www.developer.com/article.php/1460561
2. http://download.oracle.com/javase/tutorial/essential/regex/

Thursday, 2 September 2010

Create a jar file with .class file and properties files.

1. You need a menifest file:

App_Data_Export.mf

its content should look like this:

Manifest-Version: 1.0
Main-Class: App_Data_Export
Class-Path: . jars/commons-cli-1.0.jar jars/commons-lang-2.4.jar jars/commons-logging-1.1.1.jar jars/jdbcpersistence.jar jars/log4j-1.2.8.jar conf/test/.

all the paths are relative to the jar file being created and conf/test folder contains all the properties file.

2. Create a jar file.
$jar cmf App_Data_Export.mf App_Data_Export.jar App_Data_Export.class

3. To run the jar.
java -Xmx1024M -jar ${DATA_EXPORT_JAR} -config ${BASE_CONFIG_FILE} -filename ${DATA_FILE_PATH}/${DATA_FILE_NAME} -user cmms -password cmms | tee -a ${LOG_FILES}/${LOG_FILE_NAME}

where:
1. ${DATA_EXPORT_JAR} is the path of the JAR File we just created
2. -config and -filename are arguments to the main class.
3. tee -a ${LOG_FILES}/${LOG_FILE_NAME}, allows you to put the output to the output file and also see the output on the standard output.

Enjoy :).

Executive Summary: Anthropic's Claude Mythos Model

  What Happened Anthropic announced  Claude Mythos Preview , a new AI model it describes as its most capable ever — and so powerful in cyber...