#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    4
    Rep Power
    0

    fails to compile :(


    Hi.. im having a problem compiling my program... would really appriciate some help!
    here's the code

    "

    import java.awt.*;
    import java.net.URL.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.io.*;




    public class Line extends JApplet {
    int lasty=0;
    int lastx=0;
    int biggest=0;
    int yintervall;
    int punktery[]=new int[5];
    StringBuffer buff;
    String apa = "a";
    String skilj ="|";
    int b=0;


    public void paint(Graphics g) {

    try {
    URL u=new URL("http://www.sweform.com/graf_data.txt");
    BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream()));
    buff=new StringBuffer();
    String line;
    while ((line = in.readLine()) != null)
    buff.append(line);
    in.close();

    } catch (MalformedURLException e) {}

    int end,start=0;
    for(int i=0; i<punktery.length; i++) {
    start=buff.indexOf(skilj,start);
    end=buff.indexOf(skilj,start);
    String mini=buff.substring((start+1),end);
    int convInt= new Integer(mini).intValue();
    punktery[i]=convInt;

    if(punktery[i]>biggest)
    biggest=punktery[i];
    }

    yintervall=biggest/6;

    Graphics2D g2 = (Graphics2D) g;

    g2.draw(new Line2D.Double(10, 0,
    10, 180));
    g2.draw(new Line2D.Double(10, 180,
    180, 180));

    for(int i=0; i<180; i+=30)
    g.drawString(apa, 0, i);

    Integer c=new Integer(b);
    for(int i=10; i<180; i+=30) {
    g.drawString(c.toString(), i, 190);
    b++;
    c=new Integer(b);
    }


    for(int i=0; i<punktery.length; i++) {
    g2.draw(new Line2D.Double(10+lastx, (180-lasty),
    10+i, (180-punktery[i])));
    lasty=punktery[i];
    lastx=i;
    }

    }
    }

    "

    the compiler gives me the following errors

    line.java:26: cannot resolve symbol
    symbol : class URL
    location: class Line
    URL u=new URL("http://www.sweform.com/graf_data.txt");
    ^
    line.java:26: cannot resolve symbol
    symbol : class URL
    location: class Line
    URL u=new URL("http://www.sweform.com/graf_data.txt");
    ^
    line.java:34: cannot resolve symbol
    symbol : class MalformedURLException
    location: class Line
    } catch (MalformedURLException e) {}
    ^
    3 errors
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Bogotá, Colombia
    Posts
    43
    Rep Power
    12
    You have to import java.net.*, as the URL and MalformedURLException classes are defined in that package.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    4
    Rep Power
    0

    thnx


    thanks!
    it does compile now however im not sure that the code extracts the numbers between the "|" signs (check the url in the code).... is the code correct?

IMN logo majestic logo threadwatch logo seochat tools logo