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++;

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.

  • 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.

  • 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 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

  • 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;
    }

  • 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.

  • How doest jdk docs help as in writing java code?

    hi i wonder how does jdk docs help as in writing java code because if i google a java code the jdk docs always becomes the result of my search but in my experience jdk docs never helps me.
    is there any one know how to use jdk docs? and how to get the code from there.
    im telling about jdk docs from here http://download.oracle.com/javase/1.4.2/docs/api/
    cross posted from http://www.thenewboston.com/forum/viewtopic.php?f=119&t=13778
    Edited by: 871484 on Jul 18, 2011 4:18 PM

    871484 wrote:
    ok can any one give me example how to use jdk docs? for example this code
    Your question still does not make any sense, and you still haven't clarified what you're not understanding.
    However, if you think that just by reading the API docs, with no other training or study, that you will be able to write that code, then you are seriously misunderstanding the purpose of the docs.
    Obviously English is not your native language. You grew up speaking some other language at home and with your friends, and at some point in school or as private study, you started to learn English. You learned about the grammar and the alphabet and pronunciation, sentence structure, word order, etc. Now you have the basics of how the language works, and you know some words. When you want to learn new words to fit into the structure you have learned, you use a dictionary.
    If you didn't study the grammar, sentence structure, etc., and just said, "I want to learn English. I will look at a dicationary," clearly that would not work.
    Right?
    So, since you now understand and agree with the English example, let me state something that I hope is obvious to you by now: The API docs are your dictionary. They are not a substitute for learning the language basics.
    Furthermore, once you know the language basics in English and have your dictionary, you still won't know how to write a resume (which you may know as a CV). You will look at examples and perhaps take a course on resume (CV) writing. Just reading a dictionary won't help you write a resume(CV). Similarly, if you know some Java basics, you can't learn how to write a Swing app just by reading the Javadocs. You'll look at tutorials and examples. Then, once you know the basic structure of a Swing app, you'll look to the javadocs for more details about more kinds of GUI classes--different buttons and windows and panes and panels and layout managers, etc.

  • What is this Java-code doing?

    I tried to find out what this part of a JAVA code is doing.
    I think that there are the two Strings 'target' and 'phrase'
    declared and initialized, however, what is the value of each
    of these two Strings then respectively what is the return value??
    Here youe see the code:
    1:....
    2: private String O00OoO0O0oOoo00O00oo(String target, String phrase)
    3: {
    4: for(; target.length() > phrase.length(); phrase += phrase);
    5: String s1 = "";
    6: for(int i = 0; i < target.length(); i++)
    7: s1 = s1 + "" + (char)((phrase.charAt(i) + target.charAt 8: (i)) - i);
    9:
    10: return s1;
    11: }
    thx for help!

    I wrote the following program :
    public static void{
    1: private String abcdefghabcdefgh(String target, String phrase)
    2: {  
    3: for(; target.length() > phrase.length(); phrase += phrase);
    4: String a = "";
    5: for(int i = 0; i < target.length(); i++)
    6: a = a + "" + (char)(target.charAt(i) - phrase.charAt(i) - i);
    7: System.out.println(a);
    8: return a;
    9: }
    10: String pass="xxxx";
    11: String ssap="oooo";
    12: String test = "";
    13: test = abcdefghabcdefgh(pass, ssap);
    14: System.out.println(test);
    15:}
    But I always got an error when I tried to compile it...
    and i tried to find out for hours a de5cription for this function...
    Actually I found the de5cription for String(String original) in the
    API documentation, and I think this is what I wrote in line 1...
    I tried so much versions so that this function would work...
    but it didn't at all. (Actually I think that I importet all the java classes
    I need). What the hell are I'm doing Wrong???!!!

  • Does anybody know what is wrong with my java code?

    Does anybody know what is wrong with my java code?
    --------------------Configuration: <Default>--------------------
    stockApplet.java:47: cannot find symbol
    symbol : variable M_pointThread
    location: class StockApplet
    if (M_pointThread==null)
    ^
    stockApplet.java:49: cannot find symbol
    symbol : variable M_pointThread
    location: class StockApplet
    M_pointThread=new Thread(this);
    ^
    stockApplet.java:50: cannot find symbol
    symbol : variable M_pointThread
    location: class StockApplet
    THE CODE:
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    public class StockApplet extends java.applet.Applet implements Runnable
    int Move_Length=0,Move_Sum=0;
    String FileName,Name_Str,Content_Date;
    int SP[]=new int[2000];
    int KP[]=new int[2000];
    int JD[]=new int[2000];
    int JG[]=new int[2000];
    int Mid_Worth[]=new int[2000];
    String myDate[]=new String[2000];
    double CJL[]=new double[2000];
    double MaxCJL,MidCJL;
    Label label[]=new Label[10];
    int MaxWorth,MinWorth;
    int x_move0,x_move1,MaxLength=0;
    int x0,y0,X,Y,Record_Num;
    boolean Mouse_Move,Name_Change=true;
    int JX_Five1,JX_Five2,JX_Ten1,JX_Ten2;
    public void init()
    TextField text1=new TextField();
    Thread M_pointThread=null;
    setLayout(null);
    this.setBackground(Color.white);
    this.setForeground(Color.black);
    for(int i=1;i< 10;i++)
    label=new Label();
    this.add(label[i]);
    label[i].reshape(i*80-65,10,50,15);
    if(i==2){label[i].reshape(80,10,70,15);}
    if(i==7){label[i].reshape(510,10,80,15);}
    if(i >7){label[i].reshape((i-8)*490+45,380,70,15);}
    FileName="six";
    Name_Str="six";
    this.add(text1);
    text1.reshape(150,385,70,20);
    text1.getText();
    public void start()
    if (M_pointThread==null)
    M_pointThread=new Thread(this);
    M_pointThread.start();

    Welcome to the forum. I think that George123 has your problem and its solution well in hand. Follow his good advice and you will have solved this problem. One other thing though just for future reference. If you post your code, here, you are going to want someone to be able to read it easily. Please use code tags when posting next time and your code will be much easier on the eye. You can find out about them here:
    http://forum.java.sun.com/help.jspa?sec=formatting

  • 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/

  • Help Needed in AD Connection form Java Code

    Hi,
    I want to connect to AD target form my java program.
    We are doing this as we don't want to use the OOTB Connectors.
    How can any one connect to AD target from Java program?
    After connecting,
    How to Create a User in AD? Is there any API? Which one?
    Regards,
    SK

    You'll want to do a search on JNDI and Java code. There are lots of sample code available on the web and tutorials. Here's a list of the classes you'll probably be using:
    import javax.naming.CommunicationException;
    import javax.naming.Context;
    import javax.naming.NameNotFoundException;
    import javax.naming.NamingEnumeration;
    import javax.naming.NamingException;
    import javax.naming.OperationNotSupportedException;
    import javax.naming.directory.Attribute;
    import javax.naming.directory.Attributes;
    import javax.naming.directory.BasicAttribute;
    import javax.naming.directory.BasicAttributes;
    import javax.naming.directory.DirContext;
    import javax.naming.directory.InitialDirContext;
    import javax.naming.directory.ModificationItem;
    import javax.naming.directory.SearchControls;
    import javax.naming.directory.SearchResult;
    -Kevin

  • 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).

Maybe you are looking for

  • How do I backup photos to an external drive (like a passport drive)

    I have photos in  iphoto that I want to backup on an external drive.  What process do I use?

  • Profit Center Not Displaying in FBL5N

    FI Experts, We are implementing SD, we enter a profit center in the sales order, which it carried all the thru to the billing document. However when I go into FBL5N to run list of open items and bring the Profit Center fields they are all blank. If I

  • How to hide the first 2 levels of Hierarchey in bex

    Hi Guys, I am using Sales Office Hierarchy in report. Hierarchy name is 'First Sales Hierarchy' which is coming as a root node.My requirement is that I do not want to see the first 2 levels of hierarchy,but I want to see the all 3rd level hierarchies

  • [SOLVED] Laptop doesn't suspend anymore when closing lid [GNOME 3]

    Hi there! Since I upgraded to GNOME 3 recently, my laptop (Acer Aspire TimelineX 3820TG) doesn't suspend anymore when I close the lid. Instead, it just turns off the screen. If I choose suspend from the menu, it does suspend properly. I googled a bit

  • Custom pseudo classes

    Hi! How can I create my own CSS pseudo classes in Java FX 2? So that I could use a CSS file like *.MyButton : online{ }* In FX 1 it could be done by overriding methods like public long impl_getPseudoClassState() {} but they are now deprecated :-( Is