Help in my java code?

below is my code:
import java.lang.String;
import java.io.*;
import java.util.*;
public class DNASequence{
public static void main(String args[])throws IOException{
  BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  String sequenceAn = "ggctggacta ttgagatgcg ggaagagctg cagactccgg tggataaact atttgagacc cgatatcaag agaggaaact tcacaagaga agaagaggaa gctatcatta agttgcatga aatgctgggt aacaggtggt cagcaattgc agcaagatta ccaggacgca cagacaacga gataaaaaat gtatggcaca cccacttgaa gaag";
  String sequence = "DNA";
  String origin = "Prunus persica (peach)";
  String uppercase = sequenceAn.toUpperCase();
  int count = 0;
    for (int i = 0; i < sequenceAn.length(); i++) {
        char c = sequenceAn.charAt(i);
        if (c=='T' || c=='C' || c=='G' || c=='A' || c=='t' || c=='c' || c=='g' || c=='a') {
        count++;
    System.out.println("Sequence: " + sequence);
    System.out.println("Sequence length (nt): " + " " + count + "nt");
    *int counter = 1;*
*//find how many times to substring*
*int num = (int)Math.round(sequenceAn.length()/66);*
*int firstParam = 0;*
*int secondParam = 66;*
*for (int i = 0; i < num; i++) {*
*System.out.print(counter + " ");*
*System.out.println(sequenceAn.substring(firstParam,secondParam)); //print from index 0 to index 64 = 65chars*
*firstParam = firstParam + 66;*
*secondParam = secondParam + 66;*
*counter = counter + 60;*
    //System.out.println("Sequence annotation :" + uppercase);
    System.out.println("Organism origin :" + origin);
}output is below:
Sequence: DNA
Sequence length (nt): 214nt
*1 ggctggacta ttgagatgcg ggaagagctg cagactccgg tggataaact atttgagacc*
*61 cgatatcaag agaggaaact tcacaagaga agaagaggaa gctatcatta agttgcatga*
*121 aatgctgggt aacaggtggt cagcaattgc agcaagatta ccaggacgca cagacaacga*
Organism origin :Prunus persica (peach)
my problem now is it should be like this
Sequence: DNA
Sequence length (nt): 214nt
*1 ggctggacta ttgagatgcg ggaagagctg cagactccgg tggataaact atttgagacc*
*61 cgatatcaag agaggaaact tcacaagaga agaagaggaa gctatcatta agttgcatga*
*121 aatgctgggt aacaggtggt cagcaattgc agcaagatta ccaggacgca cagacaacga*
*181 gataaaaaat gtatggcaca cccacttgaa gaag*
Organism origin :Prunus persica (peach)
my another line is not display. please help me. thanks
Edited by: williamku87_1 on Apr 6, 2010 10:56 AM
Edited by: williamku87_1 on Apr 6, 2010 10:57 AM

1. In the future, please use a meaningful subject line, like "loop not performing last iteration." Just saying "Help in my java code" is useless. We know you need help with your Java code, else you wouldn't be posting here.
2. Repost your code without those annoying superfluous asterisks, and with proper indentation in the section that they are currently polluting. It's too hard to read as-is.

Similar Messages

  • Help in translating JAVA code into CF

    Hi all!  I'm at the end of integrating an in-house calendar with Google calendars and all is working, however, I am stumped as to how implement callback functions.  Here's what I'm trying to do as outlined on http://code.google.com/p/google-api-java-client/source/browse/Batch.wiki?repo=wiki
    What I need to do is this section right here:
    JsonBatchCallback<Calendar> callback = new JsonBatchCallback<Calendar>() {
      public void onSuccess(Calendar calendar, HttpHeaders responseHeaders) {
        printCalendar(calendar);
        addedCalendarsUsingBatch.add(calendar);
      public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
        System.out.println("Error Message: " + e.getMessage());
    And then later pass it to:
    client.calendars().insert(entry1).queue(batch, callback);
    I believe I can pass one function by passing just the name of the function, but BatchCallback has two functions.  Is this impossible to do in CF?
    Thanks,
    Ross.

    1. In the future, please use a meaningful subject line, like "loop not performing last iteration." Just saying "Help in my java code" is useless. We know you need help with your Java code, else you wouldn't be posting here.
    2. Repost your code without those annoying superfluous asterisks, and with proper indentation in the section that they are currently polluting. It's too hard to read as-is.

  • Run chm help file through java code

    hello,
    would you tell me how can i run a help.chm file using java code. i am trign this but no luck.
    first try
    Process pp=run.exec("C:/Program Files/Internet Explorer/IEXPLORE.exe ./res/bobftphelp.chm" );
    Second try
              Process pp=run.exec(" ./res/bobftphelp.chm" );
    It run fine a help.doc file but not help.chm file.
    please help me
    Thanka in advance
    Ravi Charan

    The second address given to that function, does it relate to the class that its being called from? cause i've got
    Runtime.getRuntime().exec("C:\\WINDOWS\\hh.exe .\\HelpFile_9_3.chm" );where HelpFile_9_3 is in the same folder as my class, but it won't work. Can anyone help?
    Also, can you search within a chm file from Java? If I get that above code working, I presume it'll open the help file to the main page. I'd like to search within that document for a word or phrase - possible?
    Thanks!
    Edited by: Pulkse.co.uk on Sep 10, 2008 8:18 AM

  • Help fix my java code!

    I am a java student in high school, and im attempting to create a program to figure how many items i can buy without going over a set price. I do not have all the equations in yet (i need to figure them out).... but can u help me fix my code please!!! More than likely all of my errors are from being new at java programming.... but please help lol! (if at all possible, i need to stay in the javax.swing and not any other import declarations)
    if i need to explain what im doing anywhere, just reply and say u don't understand it or something.
    import javax.swing.*;
    class SmeltingConversion
    public static void main(String args[])
      int amount, equation, coal_qty, iron_qty, coal_price, iron_price, gold_qty, iron_input, gold_input, coal_input, mythreal_input, mythreal_qty, adament_input, adament_qty, rune_input, rune_qty, select;
      JOptionPane.showMessageDialog(null, "Created by:\n\tFinalFntsy3\n\nCopyright 2006", "Smelting Conversions", JOptionPane.PLAIN_MESSAGE);
      select = JOptionPane.showInputDialog("Please type one of the following numbers: 1(Bronze), 2(Iron), 3(Steel), 4(Mythreal), 5(Adament), 6(Rune).");
       switch(select)
       case 1:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         tin_input = JOptionPane.showInputDialog("Please enter the price per piece of tin.");
         copper_input = JOptionPane.showInputDialog("Please enter the price per piece of copper."); 
         gold_qty=Integer.parseInt(gold_input);
         tin_qty=Integer.parseInt(tin_input);
         copper_qty=Integer.parseInt(copper_input);
         equation = gold_qty/(tin_price + copper_price);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Bronze Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 2:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         iron_input = JOptionPane.showInputDialog("Please enter the price per piece of iron ore."); 
         gold_qty=Integer.parseInt(gold_input);
         coal_qty=Integer.parseInt(coal_input);
         iron_qty=Integer.parseInt(iron_input);
         equation = gold_qty/(iron_price + (2*coal_price));
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Steel Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 3:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         mythreal_input = JOptionPane.showInputDialog("Please enter the price per piece of mythreal ore."); 
         gold_qty=Integer.parseInt(gold_input);
         coal_qty=Integer.parseInt(coal_input);
         mythreal_qty=Integer.parseInt(mythreal_input);
         equation = gold_qty/(tin_qty + copper_qty);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Mythreal Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 4:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         adament_input = JOptionPane.showInputDialog("Please enter the price per piece of adament ore."); 
         gold_qty=Integer.parseInt(a_input);
         coal_qty=Integer.parseInt(coal_input);
         adament_qty=Integer.parseInt(adament_input);
         equation = gold_qty/(tin_qty + copper_qty);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Adament Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 5:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         rune_input = JOptionPane.showInputDialog("Please enter the price per piece of rune ore."); 
         gold_qty=Integer.parseInt(a_input);
         coal_qty=Integer.parseInt(coal_input);
         rune_qty=Integer.parseInt(rune_input);
         equation = gold_qty/(tin_qty + copper_qty);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Rune Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
      JOptionPane.showMessageDialog(null, "Total amount of coal needed:\n \t" + a + "\nTotal amount of iron needed:\n \t", "Smelting Conversions", JOptionPane.PLAIN_MESSAGE);
    }

    There are a lot of things to fix within your Program.
    Why don't you try to fix your compiler errors by yourself before you ask others to do it for you ?
    JOptionPane.showInputDialog returns a String and that can't be convertet to an int without parsing the String.
    Some variables ar simply not declared and so on.
    I've tried to fix the first switich case for you so you can see how it could possibly look like
    int  coal_qty, iron_qty, coal_price, iron_price, gold_qty, iron_input, coal_input, mythreal_input, mythreal_qty, adament_input, adament_qty, rune_input, rune_qty;
      int selectId;
      String select ;
      double amount = 0.0;
      double equation;
      JOptionPane.showMessageDialog(null, "Created by:\n\tFinalFntsy3\n\nCopyright 2006", "Smelting Conversions", JOptionPane.PLAIN_MESSAGE);
      select = JOptionPane.showInputDialog("Please type one of the following numbers: 1(Bronze), 2(Iron), 3(Steel), 4(Mythreal), 5(Adament), 6(Rune).");
      selectId = Integer.parseInt(select);
    switch(selectId)
       case 1:
           String gold_input;
           String tin_input;
           String copper_input;
           double tin_price = 1.0;
           double copper_price = 1.0;
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         tin_input = JOptionPane.showInputDialog("Please enter the price per piece of tin.");
         copper_input = JOptionPane.showInputDialog("Please enter the price per piece of copper."); 
         tin_price = Double.parseDouble(tin_input);
         copper_price = Double.parseDouble(copper_input);
         gold_qty=Integer.parseInt(gold_input);
         equation = gold_qty/(tin_price + copper_price);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Bronze Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       }

  • Help in using JAVA code in SAP XI

    Hi,
    I have some java and jar files, I want to use those files through SAP XI.
    Scenario:
    we need to do encryption of some data field which is coming as input to XI, Now here we have a readymade code for encryption in JAVA that we have to use. Now we have imported all the JAVA and jar files in the XI. and written a small code in XI editor which is calling some function of JAVA file. But we are getting error that system is not able to resolve the function name.
    I think we need to define class path somewhere in XI.
    Please help me to resolve this issue.
    Thanks.

    Hi Vin,
    Here's all you should need to do:
    1) Import the jar files into the IR as an Imported Archive.
    2) You can then reference this from Message Maps (and XSLT maps). To do this in a Message Map:
    a) Create a user-defined function.
    b) Make sure to include the class in the import section. com.company.xi.MyClass for example.
    The Imported Archive and the Message Map (or XSLT map) need to be in the same software component. If they're not, you'll need to setup dependencies in the SLD between the software components.
    Thanks,
    Jesse

  • Help me doing java code

    Iam having a file "source.txt" in which i have HTML source of a HTML file containing hyperlinks..for example,The following is the content of file source.txt
    <HTML>
    <BODY>
    Yahoo
    Rediff
    Google
    </BODY>
    </HTML>
    From the above notepad file i have to extract only the links from it and save it in another notepad file say links.txt and the content should be
    www.yahoo.com
    www.rediff.com
    www.google.com
    For this i need a Java program..
    Can u please help me out for this...i need the code please..

    import java.util.regex.*;
    import java.io.*;
    import java.nio.*;
    import java.nio.charset.*;
    import java.nio.channels.*;
    public class CharBufferExample {
    public static void main(String[] args) throws Exception {
    // Create a pattern to match comments
    Pattern p = Pattern.compile("<a href[\"]{0,1}([a-zA-Z0-9.-]{0,})[\"]{0,1}[a-zA-Z0-9.- =\'\"_]{0,}>");
    // Get a Channel for the source file
    File f = new File("source.txt");
    FileInputStream fis = new FileInputStream(f);
    FileChannel fc = fis.getChannel();
    // Get a CharBuffer from the source file
    ByteBuffer bb = fc.map(FileChannel.MAP_RO, 0, (int)fc.size());
    Charset cs = Charset.forName("8859_1");
    CharsetDecoder cd = cs.newDecoder();
    CharBuffer cb = cd.decode(bb);
    // Run some matches
    Matcher m = p.matcher(cb);
    while (m.find()) {
    String str = m.group(1);
    System.out.println("Found url: "+str);
    // code to add that url to any array/vector/other containers
    // arr=str;
    // i++;

  • Needed help with updating java code

    Hello all,
    Let me begin by let you know I am not a programmer and I have tried to solve this by reading on the net. I am a network admin so I tech knowledge but no programming.
    I have a webcam sending a Jpg to an FTP site and there I have used an applet called view.class to refresh once a second.
    site:http://70.154.170.253/webcamold.html
    My problems is now that it refreshes the same image over and over. It refreshes the cached image not the new image.
    From reading I suspect that it has to do with the newer version of java (it used to work fine).
    I have tried using JavaCam but same issue it just refreshes cached image. Also image flickers, the applet I am trying to fix was really smooth.
    I have also tried to compile code that I found on this forum but I got error dealing with deprecated code.
    Any help would be greatly appreciated!!!
    Code:
    import java.applet.Applet;
    import java.awt.*;
    import java.io.PrintStream;
    public class View extends Applet
    implements Runnable
    public void init()
    setBackground(Color.white);
    String s = getParameter("refresh");
    if(s == null)
    update = 30;
    else
    try
    update = Integer.parseInt(s);
    catch(Exception _ex)
    update = 30;
    filename = getParameter("picture");
    if(filename == null)
    System.out.println("No filename given as parameter.");
    md = new MediaTracker(this);
    off = createImage(size().width, size().height);
    refreshImage();
    public void paint(Graphics g)
    g.drawImage(off, 0, 0, this);
    public void update(Graphics g)
    paint(g);
    public void refreshImage()
    img = getImage(getDocumentBase(), filename);
    md.addImage(img, 0);
    try
    md.waitForID(0);
    catch(Exception exception)
    exception.printStackTrace();
    Graphics g = off.getGraphics();
    g.drawImage(img, 0, 0, this);
    img.flush();
    public void run()
    while(th != null)
    try
    refreshImage();
    repaint();
    Thread.sleep(update * 1000);
    catch(Exception exception)
    System.out.println("Error when thread was supposed to sleep: " + exception.getMessage());
    public void start()
    if(th == null)
    th = new Thread(this);
    try
    th.start();
    return;
    catch(Exception exception)
    System.out.println("Couldn't start thread: " + exception.getMessage());
    return;
    } else
    return;
    public void stop()
    if(th != null)
    th.stop();
    th = null;
    public void destroy()
    stop();
    public View()
    update = 30;
    Thread th;
    String filename;
    int update;
    Image img;
    Image off;
    MediaTracker md;

    This is compile error free code and regarding your issues i don't think am good at this stuff
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.MediaTracker;
    public class View extends Applet implements Runnable {
         Thread th;
         String filename;
         int update;
         Image img;
         Image off;
         MediaTracker md;
         public void init() {
              setBackground(Color.white);
              String s = getParameter("refresh");
              if (s == null) {
                   update = 30;
              } else {
                   try {
                        update = Integer.parseInt(s);
                   } catch (Exception _ex) {
                        update = 30;
              filename = getParameter("picture");
              if (filename == null) {
                   System.out.println("No filename given as parameter.");
              md = new MediaTracker(this);
              off = createImage(size().width, size().height);
              refreshImage();
         public void paint(Graphics g) {
              g.drawImage(off, 0, 0, this);
         public void update(Graphics g) {
              paint(g);
         public void refreshImage() {
              img = getImage(getDocumentBase(), filename);
              md.addImage(img, 0);
              try {
                   md.waitForID(0);
              } catch (Exception exception) {
                   exception.printStackTrace();
              Graphics g = off.getGraphics();
              g.drawImage(img, 0, 0, this);
              img.flush();
         public void run() {
              while (th != null) {
                   try {
                        refreshImage();
                        repaint();
                        Thread.sleep(update * 1000);
                   } catch (Exception exception) {
                        System.out.println("Error when thread was supposed to sleep: "
                                  + exception.getMessage());
         public void start() {
              if (th == null) {
                   th = new Thread(this);
                   try {
                        th.start();
                        return;
                   } catch (Exception exception) {
                        System.out.println("Couldn't start thread: "
                                  + exception.getMessage());
                   return;
              } else {
                   return;
         public void stop() {
              if (th != null) {
                   th.stop();
                   th = null;
         public void destroy() {
              stop();
         public View() {
              update = 30;
    }

  • Help needed on java code

    Hi all,
    In the below code, if condition is failing. what might be the reason.......??
    String mAmtBaseStr = "-00000000000200.00";
              if (mAmtBaseStr.substring(0).equals("-"))
                   //strip "-" from first char
                   int len1 = mAmtBaseStr.length();
                   mAmtBaseStr = mAmtBaseStr.substring((1 - 0),len1);
                   //put the stripped "-" at last
                   mAmtBaseStr = mAmtBaseStr + "-";
    I tried other options like,
              if (mAmtBaseStr.substring(0,1).equals("-"))  etc etc......

    Hi,
            This code fails because of this reason
    _problem1 _
    String mAmtBaseStr = "-00000000000200.00";
    mAmtBaseStr.substring(0)-------> -00000000000200.00 [as substring(0) returns entire string starting from index zero.]
    when you are writing
    if (mAmtBaseStr.substring(0).equals("-"))
         You are tryring to check if the value mAmtBaseStr.substring(0) [ "-00000000000200.00"] is equal to string "-" or not.
          As you can see the strings are not equal the if condition never returns you true value.
    _Problem2_
    you are nowhere checking whether the inbound string is null or empty. In case the string comes as null or empty java will throw an exception and your mapping will fail. So if input string does not begin with an hyphen you need to pass it as it is
    Thus I would modify your code a little bit to make it work
    public static String removeHyphen(String mAmtBaseStr)
              if (mAmtBaseStr!=null && mAmtBaseStr!="" && mAmtBaseStr.substring(0,1).equals("-"))
                   //strip "-" from first char
                   int len1 = mAmtBaseStr.length();
                   mAmtBaseStr = mAmtBaseStr.substring((1 - 0),len1);
                   //put the stripped "-" at last
                   mAmtBaseStr = mAmtBaseStr + "-";
              return mAmtBaseStr;
    This code works and produces required output
    input: -00000000000200.00
    output: 00000000000200.00-
    Regards
    Anupam

  • Require  help in my ABAP code

    Hi All,
    My design wont allow Delta loads because the transformation source is an InfoSet.  To limit the data in these loads, I require a  filter in the DTPs on fiscal year/period then only load I can load the current month and 2 prior months.  Now we are updating manually for the DTPs.   To eliminate this monthly task a dynamic filter (routine) needs should be used rather than a static filter.
    So I have written as follows  But in the debugger mode am able to see the -3months to the current date but records are not filtered. Any help please
    *&  Include           RSBC_SEL_ROUTINE_TPL -
    program conversion_routine.---
    Type pools used by conversion program---
    type-pools: rsarc, rsarr, rssm.---
    tables: rssdlrange.---
    Global code used by conversion rules---
    $$ begin of global - insert your declaration only below this line  ----
    TABLES: ...---
    DATA:   ...------
    $$ end of global - insert your declaration only before this line   ----
        Fieldname       = F139---
        data type       = NUMC---
        length          = 000007---
    form compute_F139---
      tables l_t_range structure rssdlrange---
      changing p_subrc like sy-subrc.---
          Insert source code to current selection field---
    $$ begin of routine - insert your code only below this line        ----
      data: l_idx like sy-tabix.---
      read table l_t_range with key---
           fieldname = '/bic/0FISCPER' .---
      l_idx = sy-tabix.---
      DATA: w_date TYPE SY-DATUM,---
          w_date1 type sy-datum,---
          lv_idate(8) type n,---
          lv_odate(8) type n,---
          lv_date1(7) type n,---
          lv_date2(8) type n.---
      CONCATENATE SY-DATUM0(4) SY-DATUM4(2) sy-datum+6(2) into W_DATE.---
      CALL FUNCTION 'SEPA_MANDATE_ADD_MONTH_TO_DATE'---
        EXPORTING---
          MONTHS  = '-3'---
          OLDDATE = W_DATE---
        IMPORTING---
          NEWDATE = W_DATE1.---
      Concatenate W_DATE0(4) W_DATE4(2) W_DATE+6(2) into lv_Idate.---
      Concatenate W_DATE10(4) W_DATE14(2) W_DATE1+6(2) into lv_odate.---
      Concatenate '0' W_DATE4(2) '.' W_DATE0(4) into lv_date2.---
       Concatenate '0' W_DATE14(2)  W_DATE10(4) into lv_date1.---
    CALL FUNCTION 'UMC_CALDAY_TO_FISCPER'---
       EXPORTING---
        I_PERIV    = 'K1'---
        I_CALDAY   = lv_Idate---
       IMPORTING---
         OUTPUT = lv_date1.---
    CALL FUNCTION 'UMC_CALDAY_TO_FISCPER'---
       EXPORTING---
        I_PERIV    = 'K1'---
        I_CALDAY   = lv_odate---
       IMPORTING---
         OUTPUT = lv_date2.---
    *l_t_range-iobjnm = '0FISCPER'.---
    l_t_range-fieldname = '/bic/0FISCPER'.---
    l_t_range-sign = 'I'.---
    l_t_range-option = 'GE'.---
    l_t_range-low = lv_date1.---
    *l_t_range-high = lv_date2.---
      if l_idx <> 0.---
        modify l_t_range index l_idx.---
      else.---
        append l_t_range.---
      endif.---
      p_subrc = 0.---
    $$ end of routine - insert your code only before this line         ----
    endform.---
    -Ashwin
    Edited by: ashwin kumar on Jun 16, 2010 10:04 AM

    1. In the future, please use a meaningful subject line, like "loop not performing last iteration." Just saying "Help in my java code" is useless. We know you need help with your Java code, else you wouldn't be posting here.
    2. Repost your code without those annoying superfluous asterisks, and with proper indentation in the section that they are currently polluting. It's too hard to read as-is.

  • Can anybody help on sending mail through Java Code

    I am trying to send the mail using the java code and I am unable to do it. My code is
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    public class EmailExample {
    public static void main(String[] args)
    Socket smtpSocket;
    DataOutputStream os;
    BufferedReader is;
    Date dDate = new Date();
    DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US);
    try
    smtpSocket = new Socket("www.gmail.com",80);
    os = new DataOutputStream(smtpSocket.getOutputStream());
    is = new BufferedReader(new InputStreamReader(smtpSocket.getInputStream()));
    System.out.println("Hi How is this?");
    os.writeBytes("HELLO\r\n");
    // You will add the email address that the server
    // you are using know you as.
    os.writeBytes("MAIL From: <[email protected]>\r\n");
    // Who the email is going to.
    os.writeBytes("RCPT To: <[email protected]>\r\n");
    //IF you want to send a CC then you will have to add this
    //os.writeBytes("RCPT Cc: <[email protected]>\r\n");
    // Now we are ready to add the message and the
    // header of the email to be sent out.
    os.writeBytes("DATA\r\n");
    os.writeBytes("X-Mailer: Via Java\r\n");
    os.writeBytes("DATE: " + dFormat.format(dDate) + "\r\n");
    System.out.println("DATE: " + dFormat.format(dDate) + "\r\n");
    os.writeBytes("From: Me <[email protected]>\r\n");
    os.writeBytes("To: YOU <[email protected]>\r\n");
    //Again if you want to send a CC then add this.
    //os.writeBytes("Cc: CCDUDE <[email protected]>\r\n");
    //Here you can now add a BCC to the message as well
    //os.writeBytes("RCPT Bcc: BCCDude<[email protected]>\r\n");
    String sMessage = "Your subjectline here";
    os.writeBytes("Subject: Your subjectline here\r\n");
    os.writeBytes(sMessage + "\r\n");
    os.writeBytes("\r\n.\r\n");
    os.writeBytes("QUIT\r\n");
    // Now send the email off and check the server reply.
    // Was an OK is reached you are complete.
    String responseline;
    while((responseline = is.readLine())!=null)
    {   System.out.println(responseline);
    if(responseline.indexOf("Ok") != -1)
    break;
    } catch (IOException e) {
    e.printStackTrace();
    It is compiling and runnung properly. Please Help me on this.
    Thanks.
    Satya.

    You're mishandling the responses. You terminate if you don't get an "Ok" string, but that's not how success is defined - you should get a 200 code back, typically with an "OK" (not caps) message.
    It doesn't help that you're ignoring all of the server output after each command, so you never find out if anything goes wrong.
    You're also reinventing a wheel. The JavaMail API exists for this: http://java.sun.com/products/javamail/

  • Java code to create a new .txt file in FTP server  --- Help

    Hi,
    I wrote a standalone java app which creates a .txt file in my local machine and transfers it to FTP server. But my requirement now is to create a new .txt file with the same content in FTP server itself instead of creating locally with basic java code.
    I'm aware of transfering file from local machine to the FTP server using STOR command of FTP. But i never tried creating a new file & writing content into that in FTP server.
    So, if any one did this before please help me out with source code or any idea ???
    Thank you.
    Vj.

    simply_vijay wrote:
    thanks for your reply. yes i've seen the Apache Commons NET API , but there is no method or class to create a new file in FTP server. I'm really worried how to solve this problem ???Sure there is.
    There's a method where you can write data to a file on the server using an OutputStream, right? Well, instead of writing to a FileOutputStream, write to that OutputStream instead. Remember to close the OutputStream and call the method which says you're finished with the command (I forget what it's called).

  • Please help me transform this C++ code to java code....

    guys...please help me transform this C++ code to java code....please try to explain the code..thanks
    [program]
    #include <stdio.h>
    #define ALIVE 1
    #define DEAD 0
    #define SZ 33
    int stschk (int ,int );
    main()
    int s[SZ][SZ], i, j;
    for (i=0; i<sz; i++ ) s[0] = DEAD;
    for (j=0; j<sz; j++ ) s[0][j] = DEAD;
    s[0][1] = ALIVE;
    for (i=0; i<sz-1; i++) {
    for ( j=1;j<sz;j++ ) {
    s[i][j] = stschk(s[i][j-1],s[i+1][j];
    if(s[i][j-1]==ALIVE) printf("*");
    else printf(" ");
    printf("\n");
    int stschk(int s1,int s2)
    if(((s1==DEAD)&&(s2==ALIVE))||
    ((s1==ALIVE)&&(s2==DEAD))) return ALIVE;
    else return DEAD;

    Being picky, that's not C++, that's C. Standard headers in C++ dont' have .h after them, loop variables are scoped with the for, you use constants rather than #defines, etc..
    C and C++ both don't initialise arrays by default; you'd have to write an initialiser to get it to zero out the array:
        int s[sz][sz] = {};gcc will insert a call to memset to zero the array.
    If the author was assuming that the array was zeroed out, there would be no point zeroing the first row and column.
    The code reads values which haven't been initialised. If you mark such values explicitly undefined, and change the program to report an error when undefined, then you get several cases where the program makes such report.
    So either it' s a primitive random number generator (some random number generators use uninitialised memory as a source of randomness), or it's buggy, or it's processing undefined data and throwing away the result. Either way, it cannot be directly be ported to Java if the undefined values (which are limited to a small area of the ouput) are significant.

  • Please help me in compiling the enclosed java code

    Iam trying to compile the below mentioned java code and iam getting this error: I have Weblogic 6.1 + sp2 installed on my machine. Please help !
    The error is :
    C:\bea\jdk131>javac Browser.java
    Browser.java:17: cannot resolve symbol
    symbol : class JIconButton
    location: class Browser
    private JIconButton homeButton;
    ^
    Browser.java:25: cannot resolve symbol
    symbol : class ExitListener
    location: class Browser
    addWindowListener(new ExitListener());
    ^
    Browser.java:26: cannot resolve symbol
    symbol : variable WindowUtilities
    location: class Browser
    WindowUtilities.setNativeLookAndFeel();
    ^
    Browser.java:30: cannot resolve symbol
    symbol : class JIconButton
    location: class Browser
    homeButton = new JIconButton("home.gif");
    ^
    4 errors
    THE CODE IS HERE :
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    public class Browser extends JFrame implements HyperlinkListener,
    ActionListener {
    public static void main(String[] args) {
    if (args.length == 0)
    new Browser("http://www.apl.jhu.edu/~hall/");
    else
    new Browser(args[0]);
    private JIconButton homeButton;
    private JTextField urlField;
    private JEditorPane htmlPane;
    private String initialURL;
    public Browser(String initialURL) {
    super("Simple Swing Browser");
    this.initialURL = initialURL;
    addWindowListener(new ExitListener());
    WindowUtilities.setNativeLookAndFeel();
    JPanel topPanel = new JPanel();
    topPanel.setBackground(Color.lightGray);
    homeButton = new JIconButton("home.gif");
    homeButton.addActionListener(this);
    JLabel urlLabel = new JLabel("URL:");
    urlField = new JTextField(30);
    urlField.setText(initialURL);
    urlField.addActionListener(this);
    topPanel.add(homeButton);
    topPanel.add(urlLabel);
    topPanel.add(urlField);
    getContentPane().add(topPanel, BorderLayout.NORTH);
    try {
    htmlPane = new JEditorPane(initialURL);
    htmlPane.setEditable(false);
    htmlPane.addHyperlinkListener(this);
    JScrollPane scrollPane = new JScrollPane(htmlPane);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    } catch(IOException ioe) {
    warnUser("Can't build HTML pane for " + initialURL
    + ": " + ioe);
    Dimension screenSize = getToolkit().getScreenSize();
    int width = screenSize.width * 8 / 10;
    int height = screenSize.height * 8 / 10;
    setBounds(width/8, height/8, width, height);
    setVisible(true);
    public void actionPerformed(ActionEvent event) {
    String url;
    if (event.getSource() == urlField)
    url = urlField.getText();
    else // Clicked "home" button instead of entering URL
    url = initialURL;
    try {
    htmlPane.setPage(new URL(url));
    urlField.setText(url);
    } catch(IOException ioe) {
    warnUser("Can't follow link to " + url + ": " + ioe);
    public void hyperlinkUpdate(HyperlinkEvent event) {
    if (event.getEventType() ==
    HyperlinkEvent.EventType.ACTIVATED) {
    try {
    htmlPane.setPage(event.getURL());
    urlField.setText(event.getURL().toExternalForm());
    } catch(IOException ioe) {
    warnUser("Can't follow link to "
    + event.getURL().toExternalForm() + ": " + ioe);
    private void warnUser(String message) {
    JOptionPane.showMessageDialog(this, message, "Error",
    JOptionPane.ERROR_MESSAGE);

    I got this code from this forum concerning MONITORING some application. Iam working on writing something which can monitor the availabilty of my application on the browser. Iam not familiar with swings so i got confused with compiling this code.
    Please let me know if you know some code that can help me monitor my web based application.
    Thanks in advance.

  • Who can help me write this Java code show the prime number ???? PLEASEEEEEE

    Write java code print prime number like this
    Sample Screen Print:
    Initial matrix with N = 37
    2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    31 32 33 34 35 36 37
    Intermediate results (after 1st iteration)
    2 3 5 7 9
    11 13 15 17 19
    21 23 25 27 29
    31 33 35 37
    Intermediate results (after 2nd iteration)
    2 3 5 7
    11 13 17 19
    23 25 29
    31 35 37
    Intermediate results (after 7th iteration)
    2 3 5 7
    11 13 17 19
    23 29
    31 37
    Final results
    2 3 5 7 11 13 17 19 23 29
    31 37
    How to write this code ?
    Please Help me!
    Thank you so muchhh ?????

    h2. {color:#ff0000}Multiplepost{color}
    Replies here: http://forum.java.sun.com/thread.jspa?threadID=5241012&tstart=0
    There is a useful answer the original thread. Answer it, or ignore it as you like, but don't create multiple threads.

  • Need help writing Java Code

    Hi everyone, I don't know if I am in the right forum, but I am new in writing Java coding and I am confuse on what to do and how to write the code.
    I have this question and I just dont know what to do:
    How can I write a java code in the following question?
    The question:
    40 hours normal salary
    After the 40 horas, you will pay an addition 1.5 hours
    Display the total salary.
    how to I write a code for this? Thank you in advance. I know this may be very simple to you but its very hard to me. Thanks again... :)

    hi i think this is what your looking for you didnt really make it to clear but here it is anyway hope it helps
    class Hours
    public static void main (String [] args)
    //declare variables
    double hours;
    double overtime;
    double totalhours;
    System.out.println ("Enter hours worked");
    hours = Console.readDouble ();
    overtime = 1.5;
    if (hours > 40)
    totalhours = overtime + hours;
    System.out.println("You are entitled to an additional 1.5 hours");
    System.out.println("Your total hours are" + totalhours);
    else
    System.out.println ("Total hours worked are " + hours);
    }//end main
    }// End hours

Maybe you are looking for

  • HT1320 Ipod nano issues

    I Have a ipod nano 6th gen.  It is stuck on a black screen, despite trying; to connect to itunes,charge,reset etc.. when it is plugged in to charge it almost immedialty starts to get hot and continues to get warmer in temp. suggestions ?

  • Playhead won't  show and songs repeat

    Playhead won't show and songs repeat. I've turned off phone and tried to tap artwork but it still doesn't show. I just get a place to select stars for the song and it continues to play the same song over

  • Using Thai Fonts in Photoshop.

    I'd like to know how to use thai fonts in photoshop. Every time I switch the language and start typing the text appears as boxes. Thanks Derek

  • How do I delete my profile??????

    Hi guys, I want to delete my profile and be removed from the Apple Discussions....how do I do that? Also when I tried to change my email address in the 'My Settings' page, it doesn't let me change ????? Please help.... Thanks.

  • Rank calculation

    in table t1 have data like col1 col2 col3 a     a1     10 a     a2     15 a     a3     30 b     b2     37 b     b1     30 c     c1     42 d     d1     32 i want to put these data along with the rank based on col1 and col3 value . i want to put the da