comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Eclipse Tomcat Project Structure - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/69d55c013757d252
* help newbie : frame resets - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1334495f23e579d
* JRockit and thin threads?? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1875e0569618508f
* How to do bitmap icon in front of menu-items in Java? what is the class for 
menu-item in Java? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ac74a360cb38fcd
* What a mess: Date, milliseconds, GregorianCalendar - 5 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/559d9f1964889f34
* PCMCIA and COMM API - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d08b61cd45fd7071
* Strange StringIndexOutOfBoundsException - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fd07e0f1420fb8cd
* Can I put private servlet files in the WEB-INF directory? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aa64fa7ddc842466
* accessing RecordStore - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7023a70dfe7518b
* Access to Wireless LAN ... - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4b6710a272f95e58
* Custom scrollbar thumb - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f7449e31ee33ed94
* PRINTING DIAMOND SHAPE WITH LOOPS! - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/56cb33b6025f97a2
* Dynamic Casting again with array - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c39803685f52cd5
* odds and evens numbers - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/251f34d2dc2107b6
* jgrasp startup error - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/90e7404357b39172
* Help with BigInteger addition - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e0475369c4bb5de
  
==========================================================================
TOPIC: Eclipse Tomcat Project Structure
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/69d55c013757d252
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 7:17 am
From: "vivienne wykes" <[EMAIL PROTECTED]> 

Hi All,

I am using Eclipse 3.0 with a Tomcat plug in.
I am trying to create multiple web  projects using Tomcats webapps
directory. Eclipse will let me set up one project with under the webapps
folder but when I try to add a new project I get the following error
C:/jakarta-tomcat-4.1.30/webapps and C:/jakarta-tomcat-4.1.30/webapps
overlap.

This I am sure will have a simple explanation... I am thinking that it
should be ok to work on multiple web projects with different names at the
same time under Tomcats  webapps folder ?

Thanks in advance

Jim






==========================================================================
TOPIC: help newbie : frame resets
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1334495f23e579d
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 7:31 am
From: zoopy <[EMAIL PROTECTED]> 

On 24-8-2004 0:04, Madhur Ahuja wrote:
> Hello
> 
> In following code attatched, whenever I press send button, the whole of
> my frame resets. The JTextField are set to zero columns. The server field
> can
> be set to *localhost*.
> 
> Please Help, why this resetting happens.
If you enlarge the frame beyond certain size it doesn't happen anymore. It's likely 
caused by the 
improper values for GridBagConstraints' weightx/weighty. GridBagLayout is quite 
complex and I've 
always interpreted GBC weightx/y as values relative weights: a component with 
weightx==1 takes 1 
amount of the width at hand (whatever that may be), weightx==2 takes 2 amounts, a 
component with 
weightx==0 doesn't contribute for calculating the width of components with weightx>0, 
however it 
does take the space it needs. [If I'm wrong, please correct me].

I've changed the weightx/y in the code below (and some other things, such as 
justifying some fields 
horizontally).

Some other remarks:
- It's not necessary to do validate() right after pack()
- Use GridBagConstraints' fill field for justifying component 
horizontally/vertically/both
- GridBagLayout largely determines the size of a component (relative to others), 
therefore setting 
number of columns and rows of a JTextField/JTextArea isn't always honoured.
- Don't use == (or !=) for comparing String *values*: use 
someString.equals(anotherString) instead; 
to test if a string is empty you can use someString.length() == 0

-------------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.net.*;
import java.io.*;

public class mainapp implements ActionListener, KeyListener
{

   JPanel mainpanel;

   JTextField to, server, from;

   JTextArea body, result;
   JFrame mainframe;
   GridBagLayout gbc;
   GridBagConstraints constraints;
   JButton send;
   JLabel lfrom, lto, lserver, lbody, lresult, iphost;

   public mainapp()
   {

     gbc = new GridBagLayout();
     mainpanel = new JPanel(gbc);
     constraints = new GridBagConstraints();

     mainframe = new JFrame("Mail send");
     mainpanel.addKeyListener(this);
     mainframe.addKeyListener(this);
     addwidgets();

     mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     // mainframe.setSize(new Dimension(120, 40));
     mainframe.getContentPane().add(mainpanel);
     mainpanel.setPreferredSize(new Dimension(400, 400));

     mainframe.pack();
     //mainframe.validate();
     mainframe.setVisible(true);
   }

   void addwidgets()
   {
     from = new JTextField(10);
     from.setColumns(10);
     body = new JTextArea(10, 30);
     //body = new JTextArea();
     to = new JTextField(10);
     to.setColumns(10);
     server = new JTextField(10);
     server.setColumns(10);
     send = new JButton("Send");
     result = new JTextArea(4, 30);
     //result = new JTextArea();

     lfrom = new JLabel("From:");
     lbody = new JLabel("Body:");
     lto = new JLabel("To:");
     lserver = new JLabel("Server:");
     lresult = new JLabel("Result:");
     iphost = new JLabel("ffffffffff");

     from.addActionListener(this);
     to.addActionListener(this);
     server.addActionListener(this);
     send.addActionListener(this);


     buildConstraints(constraints, 0, 0, 1, 1, 0, 0);
     gbc.setConstraints(lfrom, constraints);
     mainpanel.add(lfrom);

     buildConstraints(constraints, 1, 0, 1, 1, 1, 0);
     constraints.fill = GridBagConstraints.HORIZONTAL;
     gbc.setConstraints(from, constraints);
     mainpanel.add(from);

     buildConstraints(constraints, 0, 3, 1, 1, 0, 0);
     gbc.setConstraints(lbody, constraints);
     mainpanel.add(lbody);

     buildConstraints(constraints, 1, 3, 1, 1, 1, 2);
     constraints.fill = GridBagConstraints.BOTH;
     gbc.setConstraints(body, constraints);
     mainpanel.add(body);

     buildConstraints(constraints, 0, 1, 1, 1, 0, 0);
     gbc.setConstraints(lto, constraints);
     mainpanel.add(lto);

     buildConstraints(constraints, 1, 1, 1, 1, 1, 0);
     constraints.fill = GridBagConstraints.HORIZONTAL;
     gbc.setConstraints(to, constraints);
     mainpanel.add(to);

     buildConstraints(constraints, 0, 2, 1, 1, 0, 0);
     gbc.setConstraints(lserver, constraints);
     mainpanel.add(lserver);

     buildConstraints(constraints, 1, 2, 1, 1, 1, 0);
     constraints.fill = GridBagConstraints.HORIZONTAL;
     gbc.setConstraints(server, constraints);
     mainpanel.add(server);

     buildConstraints(constraints, 2, 2, 1, 1, 0, 0);
     gbc.setConstraints(iphost, constraints);
     mainpanel.add(iphost);

     buildConstraints(constraints, 1, 4, 1, 1, 0, 0);
     constraints.fill = GridBagConstraints.NONE;
     gbc.setConstraints(send, constraints);
     mainpanel.add(send);

     buildConstraints(constraints, 0, 5, 1, 1, 0, 0);
     gbc.setConstraints(lresult, constraints);
     mainpanel.add(lresult);

     buildConstraints(constraints, 1, 5, 1, 1, 1, 1);
     constraints.fill = GridBagConstraints.BOTH;
     gbc.setConstraints(result, constraints);
     mainpanel.add(result);

   }

   public void keyTyped(KeyEvent e)
   {
     System.out.println("dfd");
     if ( from.getText().length() == 0
     ||     to.getText().length() == 0
     || server.getText().length() == 0)
     {
       send.setEnabled(false);
       System.out.println("dfd");
     }
     else
       send.setEnabled(true);
   }

   public void keyPressed(KeyEvent e)
   {
     System.out.println("dfd");
   }

   public void keyReleased(KeyEvent e)
   {
   }

   public static void main(String args[])
   {
     new mainapp();

   }

   public void actionPerformed(ActionEvent e)
   {
     if (e.getSource().getClass() == JTextField.class)
     {
       System.out.println("dfd");
       JTextField obj = (JTextField) e.getSource();
       if (obj.getText().length()==0)
       {
         send.setEnabled(false);
       }
       else
         send.setEnabled(true);
     }

     if (e.getSource() == send)
     {

       new mailit();

     }

   }

   void buildConstraints(
     GridBagConstraints gbc,
     int gx,
     int gy,
     int gw,
     int gh,
     double wx,
     double wy)
   {
     gbc.gridx = gx;
     gbc.gridy = gy;
     gbc.gridwidth = gw;
     gbc.gridheight = gh;
     gbc.weightx = wx;
     gbc.weighty = wy;
   }

   class mailit extends Thread
   {
     Socket smtpsocket;
     String host;
     InetAddress add;
     PrintWriter pw;
     BufferedReader br;
     public void run()
     {

       try
       {
         smtpsocket = new Socket();
         System.out.println(add);
         smtpsocket.connect(new InetSocketAddress(add, 25));
         br =
           new BufferedReader(
             new InputStreamReader(smtpsocket.getInputStream()));
         pw =
           new PrintWriter(new OutputStreamWriter(smtpsocket.getOutputStream()));

         pw.println("Helo mad");
         pw.println("mail from :" + from.getText());
         pw.println("rcpt to:" + to.getText());
         pw.println("data");
         pw.flush();
         pw.println(body.getText());
         pw.println(".");
         pw.flush();

         while (true)
         {
           String line = br.readLine();
           if (line == null)
             break;
           result.append(line + "\n");

           System.out.println(line);

         }

         smtpsocket.close();

       }

       catch (Exception IOException)
       {
         IOException.printStackTrace();
         JOptionPane.showMessageDialog(
           null,
           "Error during connection",
           "Mail",
           JOptionPane.ERROR_MESSAGE);
       }

     }

     mailit()
     {
       try
       {
         add = InetAddress.getByName(server.getText());
         iphost.setText(add.getHostAddress());
         System.out.println(add.getHostAddress());
         this.start();
       }
       catch (Exception UnknownHostException)
       {
         JOptionPane.showMessageDialog(
           null,
           "Cannot resolve hostname",
           "Mail",
           JOptionPane.ERROR_MESSAGE);
       }

     }

   }

}

-- 
Regards,
Z.




==========================================================================
TOPIC: JRockit and thin threads??
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1875e0569618508f
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 7:45 am
From: [EMAIL PROTECTED] (Henrik) 

[EMAIL PROTECTED] (Aquila Deus) wrote in message news:<[EMAIL PROTECTED]>...
> Hi all!
> 
> I just installed jrockit 1.4.2, but java.exe tells me " -Xthinthreads
> is no longer available". Is it just hidden or completely removed from
> jrockit? (BEA's doc doesn't mention it)

Removed for the time being. Too many problems with third-party JNI
based libraries not following the specs.

/Henrik S




==========================================================================
TOPIC: How to do bitmap icon in front of menu-items in Java? what is the class for 
menu-item in Java?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ac74a360cb38fcd
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 7:47 am
From: "Nick Pomfret" <[EMAIL PROTECTED]> 

I'm inclined to agree.  In the past I've foundJMenus and menu items quite
limited (in terms of look and feel) and have been forced to implement my
own.

-- 

** http://www.tabletoolkit.com **
Aggregate JTables to an arbitary level to create your own pivot tables


"Paul Lutus" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> gino wrote:
>
> > Hi all,
> > I have some menu-items in Java, they are "checked" menu-items... I want
to
> > change that "check tick" in front of the menu items to other bitmap icon
> > to display some fancy bitmaps in front of the menu items...
>
> So write your own MenuItem class or extension.
>
> > HOw can I do that in Java? Which class in AWT does this menu-item belong
> > to?
>
> Read the documentation.
>
> http://java.sun.com/j2se/1.3/docs/api/java/awt/MenuItem.html
>
> java.lang.Object , java.awt.MenuComponent, java.awt.MenuItem
>
> Don't cross-post without a reason.
>
> -- 
> Paul Lutus
> http://www.arachnoid.com
>






==========================================================================
TOPIC: What a mess: Date, milliseconds, GregorianCalendar
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/559d9f1964889f34
==========================================================================

== 1 of 5 ==
Date:   Wed,   Aug 25 2004 7:56 am
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

P.Hill <[EMAIL PROTECTED]> coughed up the following:
> Erwin Moller wrote:
>> Hi group,
>>
>> (Sorry for complaining)
>> Is it just me or do dates, milliseconds, GregorianCalendar completely
>> confusing?
>
> Apparently so, judging from the arguments that can erupt over such
> calculations. In the interest of trying to avoid having to explain
> this yet again to another person who thinks they know the answer and
> trying to point out that ( day1Milliseconds - day2Milliseconds ) /
> MILLISECONDS_PER_DAY is NOT the correct answer for many values of
> day1 and day2 I suggest you, the
> reader interested in this problem, see:
> http://www.xmission.com/~goodhill/dates/deltaDates.html
>
> If you have any suggestions for improvements to the article or code,
> please let me know.
>
> -Paul Hill


Curious: On all machine, in all locales, is the progression of java
milliseconds guaranteed to be linear?


-- 
"So I just, uh... I just cut them up like regular chickens?"
"Sure, just cut them up like regular chickens."





== 2 of 5 ==
Date:   Wed,   Aug 25 2004 8:15 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Thomas G. Marshall wrote:
> Curious: On all machine, in all locales, is the progression of java
> milliseconds guaranteed to be linear?

What do you mean with "linear"?



== 3 of 5 ==
Date:   Wed,   Aug 25 2004 9:17 am
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

Michael Borgwardt <[EMAIL PROTECTED]> coughed up the
following:
> Thomas G. Marshall wrote:
>> Curious: On all machine, in all locales, is the progression of java
>> milliseconds guaranteed to be linear?
>
> What do you mean with "linear"?


(?)

Are there any jump discontinuities or ramping up or ramping down to
accommodate changes in leap seconds, etc., for the odd locale?  Or is this
always true:

    java end millis - java start millis == real world end millis - real
world start millis

Given an arbitrary start and end, and an arbitrary locale.



-- 
Everythinginlifeisrealative.Apingpongballseemssmalluntilsomeoneramsitupyourn
ose.





== 4 of 5 ==
Date:   Wed,   Aug 25 2004 9:40 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Thomas G. Marshall wrote:

> Michael Borgwardt <[EMAIL PROTECTED]> coughed up the
> following:
>> Thomas G. Marshall wrote:
>>> Curious: On all machine, in all locales, is the progression of java
>>> milliseconds guaranteed to be linear?
>>
>> What do you mean with "linear"?
> 
> 
> (?)
> 
> Are there any jump discontinuities or ramping up or ramping down to
> accommodate changes in leap seconds, etc., for the odd locale?  Or is this
> always true:
> 
>     java end millis - java start millis == real world end millis - real
> world start millis
> 
> Given an arbitrary start and end, and an arbitrary locale.

Mr. Hill's earlier argument is that there are things about calendars that no
existing class accomodates. This is an easy argument to make. But the fact
is that one can get self-consistent results easily from GregorianCalendar
objects from different locations, assuming the machines' clocks and time
zones are set correctly.

"Self-consistent" only means the results agree with each other, not that
they agree with someone's arbitrary choice of reference frame. For example,
did you know that the clocks on board the GPS satellites must be made to
run at a different rate (a difference of microseconds) than those on the
ground, for relativistic reasons?

The are any number of such special reference frames, but for everyday
purposes, you can subtract two millisecond values in Java and get something
useful and consistent.

-- 
Paul Lutus
http://www.arachnoid.com




== 5 of 5 ==
Date:   Wed,   Aug 25 2004 10:08 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Thomas G. Marshall wrote:
> Are there any jump discontinuities or ramping up or ramping down to
> accommodate changes in leap seconds, etc., for the odd locale?

This really has nothing to do with Java and everything to do with how the
underlying operating system implements its clock in regard to
leap seconds, daylight savings switches, etc.

Usually, this will result in sudden leaps of clock time, e.g. when
the clock is adjusted by a Network Time Protocol client. Of course,
the same thing happens when a user adjusts the time manually.

Another notable fact is that common OS's clocks are coarser than
the millisecond precision assumed by java, so the time will appear
to progress in little jumps of about 10 milliseconds




==========================================================================
TOPIC: PCMCIA and COMM API
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d08b61cd45fd7071
==========================================================================

== 1 of 2 ==
Date:   Wed,   Aug 25 2004 8:05 am
From: [EMAIL PROTECTED] (Christian Marko) 

JScoobyCed <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Christian Marko wrote:
> 
> > Hi!
> > 
> > Does anyone have experiences with the COMM API and the usage of the
> > PCMCIA port? With the COMM API the PCMCIA ports should also be found,
> > or not?
> > 
> > I have a PCMCIA port on my notebook, but this port won't be found, by
> > the appropriate class of the COMM API. As i read in other posts, the
> > port should be found. Can anyone help me?
> > 
> > Regards
> > Chris
> 
> I would hardly believe the PCMCIA port could be found by the COMM API:
> "The Java Communications API contains support for RS232 serial ports and 
> IEEE 1284 parallel ports" (http://java.sun.com/products/javacomm/index.jsp)

OK, but i use a RS-232 serial PCMCIA card, where to the PCMCIA card 4
RS-232 ports are connected. These ports are seen by the OS (Win98,
W2K, WinXP) and listed as COM ports, but not by the COMM API.

Does you or anyone else know any alternative to the COMM API?



== 2 of 2 ==
Date:   Wed,   Aug 25 2004 9:59 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Christian Marko wrote:

> JScoobyCed <[EMAIL PROTECTED]> wrote in message
> news:<[EMAIL PROTECTED]>...
>> Christian Marko wrote:
>> 
>> > Hi!
>> > 
>> > Does anyone have experiences with the COMM API and the usage of the
>> > PCMCIA port? With the COMM API the PCMCIA ports should also be found,
>> > or not?
>> > 
>> > I have a PCMCIA port on my notebook, but this port won't be found, by
>> > the appropriate class of the COMM API. As i read in other posts, the
>> > port should be found. Can anyone help me?
>> > 
>> > Regards
>> > Chris
>> 
>> I would hardly believe the PCMCIA port could be found by the COMM API:
>> "The Java Communications API contains support for RS232 serial ports and
>> IEEE 1284 parallel ports"
>> (http://java.sun.com/products/javacomm/index.jsp)
> 
> OK, but i use a RS-232 serial PCMCIA card, where to the PCMCIA card 4
> RS-232 ports are connected. These ports are seen by the OS (Win98,
> W2K, WinXP) and listed as COM ports, but not by the COMM API.
> 
> Does you or anyone else know any alternative to the COMM API?

Your PCMCIA serial interface must be handled by the native OS. It cannot be
addressed directly by Java. Once it has the appropriate native driver, it
may appear as a serial interface, but Java cannot do the first part for you
by itself.

-- 
Paul Lutus
http://www.arachnoid.com





==========================================================================
TOPIC: Strange StringIndexOutOfBoundsException
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fd07e0f1420fb8cd
==========================================================================

== 1 of 2 ==
Date:   Wed,   Aug 25 2004 8:17 am
From: "Nick Pomfret" <[EMAIL PROTECTED]> 

What are the fields 'sb', 'lineBuffer' and 'is' and what values do they
hold?

-- 

** http://www.tabletoolkit.com **
Aggregate a JTable to an arbitrary level to create your own pivot tables


"dutone" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I get the above exception ('String index out of range: -5') at random
> points during readMultiLine()'s network read (listed below). According
> to doc. the only method that could be throwing this is sb.delete() but
> it doesnt meet the conditions for the exception.  When I run it on a
> file, no error, only when doing network io.
> Any Ideas?????
>
>
>   main()
>   {
>     //Init......
>     String lines[] = readMultiLine();
>     // ....
>   }
>
>   private  String readLine() throws IOException
>     {
> int c;
>
>     sb.delete(0,sb.length());
>     c = is.read();
>
>     while( c > 0 ) {
>         sb.append((char)c);
>   if( (char)c == '\n' ) break;
>         c = is.read();
>     }
>
>     return ( (sb.length() > 0) ? sb.toString():null);
>
>     }
>
>  private String[] readMultiLine() throws IOException
>     {
>       String retval[] = null;
>       String x = readLine();
>
>
>   lineBuffer.removeAllElements();
>           while(x != null) {
>
>      if( x.equals("^\r\n") ) break;
>
>      lineBuffer.addElement(x);
>      x = readLine();
>   }
>
>           retval = new String[lineBuffer.size()];
>   lineBuffer.copyInto(retval);
>
>
>           return (retval);
>     }





== 2 of 2 ==
Date:   Wed,   Aug 25 2004 9:58 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

dutone wrote:

> I get the above exception ('String index out of range: -5') at random
> points during readMultiLine()'s network read (listed below). According
> to doc. the only method that could be throwing this is sb.delete() but
> it doesnt meet the conditions for the exception.  When I run it on a
> file, no error, only when doing network io.
> Any Ideas?????

As others have written, provide a complete example and a full 
description of the exception (preferably including the stack trace). 
There are some problems and potential problems in your code that I can 
still comment on without that, however:

>   private  String readLine() throws IOException
>     {
>       int c;
>        
>           sb.delete(0,sb.length());

Chances are you would be better off making sb a local variable (and 
creating a new instance at each invocation of this method).

>           c = is.read();
> 
>           while( c > 0 ) {
>               sb.append((char)c);

Reading a byte from an InputStream (the presumed type of "is") and 
casting it to a char is fundamentally unsound.  You should be wrapping 
your InputStream in an InputStreamReader that specifies the correct 
character encoding for the characters.  You might still cast the 
resulting ints to char, but you would know that they actually represent 
chars.

>                 if( (char)c == '\n' ) break;

The explicit comparison against '\n' is non-portable.  It would fail on 
systems that do not use '\n' or "\r\n" as a line terminator for text 
files, such as Mac.

>               c = is.read();
>           }
> 
>           return ( (sb.length() > 0) ? sb.toString():null);       
> 
>     }
> 
>  private String[] readMultiLine() throws IOException
>     {
>       String retval[] = null;
>       String x = readLine();

See below regarding readLine().

>           
>         lineBuffer.removeAllElements();

The lineBuffer variable really ought to be local to this method.  It 
looks like a Vector; you would probably be a bit better off using one of 
the other List implementations (and the methods of the List interface 
instead of the Vector-specific ones), but that doesn't look like it's 
causing an actual problem.

>           while(x != null) {
>       
>            if( x.equals("^\r\n") ) break;

Are you trying to stop at a line containing just a single '^' character? 
  That equals() comparison is wrong if you're trying to match a blank 
line, and it will fail in many cases when the input was not generated on 
Windows.

>            lineBuffer.addElement(x);
>            x = readLine();

If you wrap your input in a BufferedReader then you can use its 
readLine() method, which solves many of the non-portable line 
termination problems exhibited by your code.  There is a difference that 
you should be aware of, however: BufferedReader.readLine() does not 
include the line termination characters (whatever they are) in the 
Strings it returns.  Using a BufferedReader is often a considerable 
performance win over an unbuffered Reader or InputStream, too.

>         }
> 
>           retval = new String[lineBuffer.size()];
>         lineBuffer.copyInto(retval);
>           
> 
>           return (retval);
>     }

I don't see the index problem in the code you posted.  Most likely it is 
in the code you did not post -- either in code that you cut out of these 
methods or in other methods.  Create a small, self-contained example 
that exhibits the bug [check that!] and post it.


John Bollinger
[EMAIL PROTECTED]





==========================================================================
TOPIC: Can I put private servlet files in the WEB-INF directory?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aa64fa7ddc842466
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 8:22 am
From: [EMAIL PROTECTED] (William Krick) 

I am currently experimenting with a servlet that makes use of data
files to store information.  I'd prefer that these files be NOT
publicly accessible but
I don't know if it's ok to put my own files into the WEB-INF directory
to "hide" them from users or if I should put them in a
hidden/protected folder OUTSIDE the deployment directory.

Is there a general consensus on this?

...
Krick




==========================================================================
TOPIC: accessing RecordStore
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7023a70dfe7518b
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 8:42 am
From: [EMAIL PROTECTED] (Marcin) 

Could you be more precise? From your post I understood that you want
to use javax.microedition.io  package. Since Nokia 6100 supports only
MIDP 1.0 this package is not accessible.

So there is no way (is there) to use serial port and to create a http
connection.

Marcin

JScoobyCed <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Marcin wrote:
> 
>  > Hi,
>  >
>  > I have a Nokia 6100 phone and I'm develoiping application that stores
>  > data via RecordStore class. The problem is I would like to have those
>  > data on my PC (i.e. via infrared link).
>  >
>  > Ideas:
>  > 1) Use infrared API - probably not possible :(
> 
> Why not. Using an IR to Serial application on your PC, and the JCA (Java 
> Comm API) you can exchange data between your phone and a computer.
> 
>  > 2) not to use RecordStore but other class (if exists) that allows me
>  > to create file (in Gallery folder maybe?). The I could access the file
>  > from Nokia PC Suite.
> 
> No. You are restricted to access data created by the JVM. You can't 
> access directly to the File System of your phone.
> 
>  > 3) Access file there RecordStore records are stored (RMS.rms?) - but
>  > how?
> 
> I am not sure about that.
> 
> I would go for a IR 2 Serial emulation on your PC, and communicate with 
> the IR RFCOMM serial connection (provided it is working on the 6100).
> Another way would be to have a (web-)server on the PC and connect it 
> through a (Http)Connection.




==========================================================================
TOPIC: Access to Wireless LAN ...
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4b6710a272f95e58
==========================================================================

== 1 of 3 ==
Date:   Wed,   Aug 25 2004 9:15 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Marco Cavaliere wrote:

> "Paul Lutus" <[EMAIL PROTECTED]> wrote in message
> 
>> > I'm start to programming java one mounth ago, and I'm try to
>> > programming
>> > a  smart-client for WLAN access, basically I need to change the ESSID
>> > for my Wireless lan CARD, and of course, I need also to retrive the
>> > list of all ESSID that the card detect, is it possible do it with java?
>> No.
>> You cannot do this without calling native methods. This is not a Java
>> issue.
> 
> Bad to hear this!
> So the only way to make it is to use external commands? that are able to
> set up the network proprieties.

Yes, because this is handled differently on each platform, it cannot be made
part of Java.

-- 
Paul Lutus
http://www.arachnoid.com




== 2 of 3 ==
Date:   Wed,   Aug 25 2004 9:32 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Paul Lutus wrote:
> Yes, because this is handled differently on each platform, it cannot be made
> part of Java.

You mean, like file systems and GUIs are different on each platform, making it
impossible to add file IO and GUIs to Java?



== 3 of 3 ==
Date:   Wed,   Aug 25 2004 9:57 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Michael Borgwardt wrote:

> Paul Lutus wrote:
>> Yes, because this is handled differently on each platform, it cannot be
>> made part of Java.
> 
> You mean, like file systems and GUIs are different on each platform,
> making it impossible to add file IO and GUIs to Java?

No, because that isn't true -- filesystems are very much alike, and it is
therefore feasible to create a single meta-filesystem in Java.

Wireless interface manipulation is different -- each platform handles it
differently, some don't handle it at all.

-- 
Paul Lutus
http://www.arachnoid.com





==========================================================================
TOPIC: Custom scrollbar thumb
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f7449e31ee33ed94
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 9:17 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Chris Uppal wrote:

> Paul Lutus wrote:
> 
>> > i'm writing an application using UIManager and metal theme.
>> > I'd like to use a bitmap to have a custom scrollbar thumb, but how can
>> > i do it ?
>>
>> Java programming?
>>
>> When you have some code, post it.
> 
> ?!
> 
> This has to be in the running for some kind of "Most Useless Response of
> the Week" award.

The OP didn't post any source code. Posting source code is essential to
making any progress. I said so.

Until he actually tries to create a class with custom graphics, and begins
to describe the specifics, any effort to discuss the issue is equivalent to
onanism.

-- 
Paul Lutus
http://www.arachnoid.com





==========================================================================
TOPIC: PRINTING DIAMOND SHAPE WITH LOOPS!
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/56cb33b6025f97a2
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 9:20 am
From: Paul Lutus <[EMAIL PROTECTED]> 

John wrote:

> Paul Lutus wrote:
>> Jay Dean wrote:
>> 
>> 
>>>I need simple nested loops (either for, or while) code for a method to
>>>print a diamond shaped stars for n stars, where n is odd.
>>>  Example. n=9 would produce
>>>
>>>        *
>>>       ***
>>>      *****
>>>     *******
>>>    *********
>>>     *******
>>>      *****
>>>       ****
>>>        *
>>> I have STRUGGLED with this for over three days in a row and my head
>>>aches!
>> 
>> 
>> Well, since you aren't really interested in learning this:
>> 
>>    void drawDiamond(int n)
>>    {
>>       int q = n/2;
>>       for(int a = -q;a <= q;a++) {
>>          int b = (a < 0)?-a:a;
>>          int c = q-b;
>>          for(int d = 0;d <= q+c;d++) {
>>             System.out.print((d < b)?" ":"*");
>>          }
>>          System.out.println();
>>       }
>>    }
>> 
>> n = 9:
>> 
>>     *
>>    ***
>>   *****
>>  *******
>> *********
>>  *******
>>   *****
>>    ***
>>     *
>> 
>> We would gladly teach you how to fish, but you clearly want to be handed
>> the fish. So be it.
>> 
> 
> Nice solution. The OP might be able to explain its workings to the
> lecturer though. Here's a more confusing version. I just wish I could
> justify some bitwise operations here.
> 
>    static void drawDiamond(int n) {
>      for(int i = -n/2;i <= n/2; i++) {
>        for(int j=0;j <= n-1-((i < 0)?-i:i);j++) {
>          System.out.print((j < ((i < 0)?-i:i))?" ":"*");
>        }
>        System.out.println();
>      }
>    }

Yes, I agree. Yours is an example of a perfectly good working solution that
no sane student would dare turn in, because he might have to try to explain
it. :)

-- 
Paul Lutus
http://www.arachnoid.com





==========================================================================
TOPIC: Dynamic Casting again with array
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c39803685f52cd5
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 9:29 am
From: "u.Shanker" <[EMAIL PROTECTED]> 

Hello !
Ok. I did my homework, by readin around, but not able to make it generic.
Problem:
I have to call ExternalClass.myMethod(InputClass[]);
Now depending on the cases InputClass and myMethods are different.
So I want to reflection.

Solution:
ExternalClass external = ...
InputClass rr = .....
InputClass[] array = new InputClass[] { rr };

GenerateProtocolObject generator = new GenerateProtocolObject(); // does the
Class.forName(classname)
Object o =generator.getObjectInstance("InputClass");

Class cls = Class.forName("InputClass");
Object arr = Array.newInstance(cls, 1);   // just trying with 1 element in
array
Array.set(arr, 0, o);
Class c = external.getClass();
Class[] parameterTypes = new Class[] {array};       // <-- this works

Method concatMethod;
Object[] arguments = new Object[] { };
  try {
      Method[] mm = c.getMethods();
      concatMethod = c.getMethod("myMethod", parameterTypes);

--
but I want something like
Class[] parameterTypes = new Class[] {o.getClass()};
Class[] parameterTypes = new Class[] {o[]};
Class[] parameterTypes = new Class[] {arr};

thanks for any comments
uma






==========================================================================
TOPIC: odds and evens numbers
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/251f34d2dc2107b6
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 9:34 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Joona I Palaste wrote:

/ ...

[ PL: ]

>>> That would be presumptuous, since a string is not a number at all.
> 

[ Liz: ]

>> It is a place to put the integer, just like double is a place to put the
>> integer.
>> ncest pas?
> 
> By that logic, we would need Math.isEven() and Math.isOdd() methods for
> every class that contains an int or double field.

More to the point, we could write the methods as (and if) the need came up.
No need to burden standard classes with whimsical methods.

-- 
Paul Lutus
http://www.arachnoid.com





==========================================================================
TOPIC: jgrasp startup error
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/90e7404357b39172
==========================================================================

== 1 of 2 ==
Date:   Wed,   Aug 25 2004 10:06 am
From: "Larry Barowski" <larrybarATengDOTauburnDOTeduANDthatISall> 


"Josh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Error occurred during initialization of VM
> java/lang/NoClassDefFoundError: java/lang/Object
>
>
> This orrcurs on both the Microsoft and Sun VM machine. Any suggestions?

The Microsoft VM is too old.

Do you have at least Sun Java 1.3?

Copy all the contents of the jGRASP control shell and send
it to graspATengDOTauburnANOTHERDOTedu  .







== 2 of 2 ==
Date:   Wed,   Aug 25 2004 10:07 am
From: "Larry Barowski" <larrybarATengDOTauburnDOTeduANDthatISall> 


"Hal Rosser" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You need the Sun JDK - not just the JVM to run JGrasp
> the jdk come with javac - which you need for JGrasp
> Install the JDK first - then install JGrasp - then JGrasp will find the
jdk
> and set itself up correctly.

The JRE is sufficient if you won't be compiling or debugging
Java code.






==========================================================================
TOPIC: Help with BigInteger addition
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e0475369c4bb5de
==========================================================================

== 1 of 1 ==
Date:   Wed,   Aug 25 2004 9:55 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Bert Sierra wrote:

> OK --
> 
> Most of the Java API makes sense to me, but there are aspects of the
> java.math.BigInteger package that have me stumped.  Any help would be
> appreciated.
> 
> In one piece of code, I was trying to add two BigIntegers, as follows:
>    BigInteger a = ...something...
>    BigInteger b = ...something...
>    BigInteger c = a.add(b);
> 
> What I quickly discovered was that in some cases the result was returned
> by destroying the value in a, and in other cases by destroying the value
> in b.

Post examples of each case. Post short, compilable, working examples. Show
the behavior you are saying exists.

-- 
Paul Lutus
http://www.arachnoid.com




=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/prefs

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/BCfwlB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/kumpulan/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to