Java argument help


 
Thread Tools Search this Thread
Top Forums Programming Java argument help
# 1  
Old 03-13-2012
Java argument help

Hello All,

I have the following code,


Code:
package com.java.tutorial.examples;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Swapping {

        /**
         * @param args
         */

	public static void main(String[] args) throws FileNotFoundException, IOException {

                 BufferedReader file1 = new BufferedReader(new FileReader("/path/1.txt"));

                 BufferedReader file2 = new BufferedReader(new FileReader("/path/2.txt"));

                 BufferedWriter writer = new BufferedWriter(new FileWriter("/path/file1_file2_distance.txt"));

                 BufferedWriter writer2 = new BufferedWriter(new FileWriter("/path/file1_file2_d.txt"));

                 int arg1 = Integer.parseInt(args[0]);

                 String s1 = null;
                 String[] s2 = new String[1000];
                 String s3 = null;
                 String[] s4 = new String[1000];
                 String s5=null;
                 String[] s6 = new String[1000];
                 int length1 = 0;
                 int length2 =0;
                 int length3 =0;
                 int length4 =0;

                 while((s1=file1.readLine())!=null)
                 {
                         s2=s1.split("\t");
                         length1 = s2.length;

                         while((s3=file2.readLine())!=null)
                         {
                                 s4=s3.split("\t");
                                 length2 = s4.length;
                                 length3 = Integer.parseInt(s4[1])-Integer.parseInt(s2[1]);
                                 if(s2[0]!=null && s4[0]!=null && s2[0].equalsIgnoreCase(s4[0]))
                                 {
                                 for(int i=0; i< length1;i++)
                                 {
                                         writer.write(s2[i] + "\t" );
                                 }

                                 for(int j=1; j< length2;j++)
                                 {
                                         writer.write(s4[j] + "\t" );
                                 }
                                 writer.write(Integer.parseInt(s4[1])-Integer.parseInt(s2[1]) + "\t" );
                                 writer.newLine();

                                 }
                         }
file2 = new BufferedReader(new FileReader("/path/2.bed"));
                 }
                 writer.close();

                 BufferedReader file3 = new BufferedReader(new FileReader("/path/file1_file2_distance.txt"));

                 while((s5=file3.readLine())!=null)
                 {
                         s6 = s5.split("\t");

                         length4 = s6.length;

                         if(Integer.parseInt(s6[length4-1])>=-arg1 && Integer.parseInt(s6[length4-1])<=arg1)
                         {
                          	for(int k=0;k<length4;k++)
                                {
                                        writer2.write(s6[k]+ "\t");
                                }
                                 writer2.newLine();
                         }
                 }
                 writer2.close();
        }
}

I would like to pass an argument to filter the difference generated between two columns.

I am using
Code:
javac -D 5000 prog.java

It is giving an error directory doesnot exist: -D

Can someone tell me how to pass that argument?

Thanks in advance.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing argument from Java to Shell script

Hi All, I want to pass array of argument from Java to a shell script.I can use process builder api and its exec() method to call the script,but the question is how to receive the parameter in the script. Thanks in advance ---------- Post updated at 10:00 PM ---------- Previous update was... (1 Reply)
Discussion started by: Abhijeet_Atti
1 Replies

2. UNIX for Advanced & Expert Users

Error:--test: argument expected--Even though i give an argument.

Hi All, I am running the script VBoxManage list vms |sed 's/"//g' | cut -d " " -f1 > har1out.mytxt result=`cat har1out.mytxt | grep $1' echo $result echo $1 { if then echo pass else echo fail fi (2 Replies)
Discussion started by: harsha85
2 Replies

3. Shell Programming and Scripting

Make script that run with argument if not run from configuration file argument

Hello, Is there any method thorugh which script can take argument if pass otherwise if argument doesn't pass then it takes the argument from the configuration file i.e I am workiing on a script which will run through crontab and the script will chekout the code ,zip and copy to the... (3 Replies)
Discussion started by: rohit22hamirpur
3 Replies

4. Shell Programming and Scripting

Cannot compare argument in if statement in csh/grep command if argument starts with “-“

If ($argv == “-debug”) then Echo “in loop” Endif But this is not working. If I modify this code and remove “-“, then it works. Similarly I am getting problem using grep command also Grep “-debug” Filename Can someone please help me on how to resolve these... (1 Reply)
Discussion started by: sarbjit
1 Replies

5. Shell Programming and Scripting

get positive number n as argument script must calculate the factorial of its argument

Can someone please help me with this SHELL script? I need to create a script that gets a positive number n as an argument. The script must calculate the factorial of its argument. In other words, it must calculate n!=1x2x3x...xn. Note that 0!=1. Here is a start but I have no clue how to... (3 Replies)
Discussion started by: I-1
3 Replies

6. UNIX for Dummies Questions & Answers

How to find the last argument in a argument line?

How to find the last argument in a argument line? (4 Replies)
Discussion started by: nehagupta2008
4 Replies
Login or Register to Ask a Question