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

Today's topics:

* File transfer - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21c48fc59bad56d9
* sorting an ArrayList by int - 13 messages, 8 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127ea15b32732f1
* How tom create a NEW class online - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1552191b47783f48
* Making multiple HTTP requests using same HttpConnection object in j2me - 1 messages, 
1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/262c1d5fa2776e3
* 1.5, rtf & word - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50f7a7e4797096a9
* unfindable statement-exception - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ccc76dd893bc29a1
* Mixing EJB 1.1 remote and 2.0 local beans within a transaction... - 1 messages, 1 
author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3bff8d99f36b1ee6
* Logging configuration file w/ web start - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/647b28fc11be9145
* c:url param encoding problem: £ (UK currency symbol) - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6fa3c5d551e4916a
* applet's call comportement - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc1d4563dc67060c
* help with my first project on first job, how to read a strange file, thanks a 
lot!!!!!!! - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8c32ba1a17d68c9a
* Multi Struts App Challenge - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b1ce0ed49d4d32ca
* How can I convert a String to an Int? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3a44aee4d751e576
* Generating the proper url - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e91af77a00eb79b2
* Challenge: Triangles puzzle - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5e013ca5d7daa5f0
  
==========================================================================
TOPIC: File transfer
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21c48fc59bad56d9
==========================================================================

== 1 of 3 ==
Date:   Mon,   Oct 25 2004 11:13 am
From: "Paul Morrison" <[EMAIL PROTECTED]> 

Hi, this is an assessment that I have for university, so I do not actually
expect people to give me answers as to what to do, I am just asking if it
would be possible for someone with more Java knowledge than me to have a
look at it and see if I going about it the correct way. Rather than try to
explain what it is I have to do, I will just paste the specification below,
with the code below that, sorry if this is not the done thing, Im relatively
new to this newsgroup lark!

Thank you for your time

Paul


------------------------------------------------

Specification:

The program AGASSI has two parameters:

  a.. the name of the host we want to connect to
  b.. the name of the file we want to read from there
  c.. AGASSI should connect at port 14152 at that host and send to the
socket the requested filename (this message goes through the IO streams and
is a complete line)
  the socket at that host should then do the following (i.e. you assume that
it does that, it is not your responsibility):
    a.. it responds line by line, the first line is an instruction; the
possible instructions (these are all strings) are:
      a.. STOP - this means that something has gone wrong and the transfer
terminates, e.g. the file is not accessible at the other end of the line
      b.. LINE - this means that the next line will be a line from the
requested text file; the one after that will be an instruction again
      c.. END - this signals the successful completion of the transfer
    b.. AGASSI should untangle these messages and put the file back together
at your site (of the same name); it should do something sensible if the
protocol is not adhered to, or other problems arise. Hint: it is advisable
to close IO streams once communication has ceased, otherwise data loss can
occur.


------------------------------------------------


Code:

import java.io.*;
import java.net.*;

public class Agassi
{

 private PrintWriter output;
 private BufferedReader input;

 public Agassi()
 {
 }

 public boolean blankLine(String s)
 {
  if (s == "LINE") {
   return true;
  }
  return false;
 }

 public boolean checkEnd(String s)
 {
  if (s == "END") {
   return true;
  }
  return false;
 }

 public static void main(String args[]) throws Exception
 {
  if(args.length != 2)
  {
   System.err.println("usage: java Agassi URL filename");
   System.exit(1);
  }
  InetAddress inetaddress = null;
  try
  {
   inetaddress = InetAddress.getByName(args[0]);
  }
  catch(UnknownHostException unknownhostexception)
  {
   System.err.println("URL " + args[0] + " doesn't work");
   System.exit(1);
  }
  Socket socket = null;
  try
  {
   socket = new Socket(args[0], 14152);
  }
  catch(Exception exception)
  {
   System.err.println("Could not connect to host");
  }
  try
  {
   BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
   PrintWriter printWriter = new PrintWriter(socket.getOutputStream(),
true);
   printWriter.println(args[1]);
   socket.setSoTimeout(1000);
   System.err.println("Here are the contents of the file:");
   do
   {
    String s = bufferedReader.readLine();
    if (s == "STOP") {
     throw new Exception("Something has gone wrong, transfer terminated");
    }
    if (s == "LINE")
     break;
    if (s == "END")
     break;
    System.out.println(s);
   } while(true);
  socket.close();
  }
  catch (IOException ioexception)
  {
   System.err.println("An error has occured: " + ioexception);
  }
 }
}







== 2 of 3 ==
Date:   Mon,   Oct 25 2004 12:11 pm
From: Paul Lutus <[EMAIL PROTECTED]> 

Paul Morrison wrote:

> Hi, this is an assessment ...

No, this is a multi-post. Never post the exact same message into more than
one newsgroup.

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




== 3 of 3 ==
Date:   Mon,   Oct 25 2004 12:30 pm
From: Oscar kind <[EMAIL PROTECTED]> 

Paul Morrison <[EMAIL PROTECTED]> wrote:
> Hi, this is an assessment that I have for university, so I do not actually
> expect people to give me answers as to what to do, I am just asking if it
> would be possible for someone with more Java knowledge than me to have a
> look at it and see if I going about it the correct way. Rather than try to
> explain what it is I have to do, I will just paste the specification below,
> with the code below that, sorry if this is not the done thing, Im relatively
> new to this newsgroup lark!

Ok, as you asked nicely and didn't ask to get your work done for you, I'll
give it a try.


[...]
> public boolean blankLine(String s)
> {
>  if (s == "LINE") {
>   return true;
>  }
>  return false;
> }

This won't work. Reread the chapter in your book on objects and
references, and think it over.
The error is repeated.


[...]
>     throw new Exception("Something has gone wrong, transfer terminated");

Ouch. This terminates your program rather suddenly. Is an IOException not
more to the point? Something went wrong with IO. Also, IOExceptions are
caught...


[...]
>  catch (IOException ioexception)
>  {
>   System.err.println("An error has occured: " + ioexception);
>  }

I'm missing something to ensure the input and output streams are always
closed. Hint: what are the blocks in try/catch/...?


-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2




==========================================================================
TOPIC: sorting an ArrayList by int
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127ea15b32732f1
==========================================================================

== 1 of 13 ==
Date:   Mon,   Oct 25 2004 11:20 am
From: Carl Howells <[EMAIL PROTECTED]> 

zcraven wrote:
> when I type this line in class 'Club' I get the error 'club is not abstract
> and does not override abstract method compareTo':
> 
>     public class Club implements Comparable
> 
> I have been stuck on this for 4 hours!
> 
> Zac
> 

Please don't top-post.

You're getting that error because your class (class names should start 
with capital letters) is not declared as abstract, and doesn't override 
the abstract method compareTo.  The compiler is telling you quite 
clearly what's going on.

In order to implement an interface in a non-abstract class, you have to 
provide implementations for the methods declared in the interface. 
Comparable happens to declare one method, named compareTo.  Check the 
documentation for Comparable to see what the method's exact signature 
should be, and what it should do when you implement it.



== 2 of 13 ==
Date:   Mon,   Oct 25 2004 11:24 am
From: "zcraven" <[EMAIL PROTECTED]> 

This is the whole code of the method I am writing:

public void printLeagueTable()
    {
        System.out.println("LEAGUE: " + leagueName);
        Collections.sort(league);

        for (int i=0; i<league.size(); i++)
        {
            Club club = league[i];    // ERROR 'array required but found
arraylist'
            String clubName = club.getClubName();
            int points = club.getPointsTally();
            System.out.println(clubName + " = " + points);
        }
    }

(the clubs in the league have other fields but I want to sort them by the
goalTally field)







"zcraven" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> when I type this line in class 'Club' I get the error 'club is not
abstract
> and does not override abstract method compareTo':
>
>     public class Club implements Comparable
>
> I have been stuck on this for 4 hours!
>
> Zac
>
>
>
> "Joona I Palaste" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > zcraven <[EMAIL PROTECTED]> scribbled the following
> > on comp.lang.java.programmer:
> > > I need to sort a football league by the number of points each club
has.
> The
> > > clubs are objects stored in an ArrayList called 'league'.  Each club
has
> a
> > > field for the number of points they have.
> >
> > > Can someone suggest the best way to sort this arraylist and output it
to
> > > screen?
> >
> > > Most examples on the web suggest I type:
> >
> > >     collections.sort(league)
> >
> > > but i get the error that it expects an Array but has found an
ArrayList.
> >
> > > PLEASE HELP! :-)
> >
> > There is a Collections.sort(List) method. Simply feed your ArrayList to
> > it with Collections.sort(league). You have to make sure your club
> > objects implement the Comparable interface though - otherwise you may
> > end up with ClassCastExceptions, or a list that is not properly sorted.
> >
> > -- 
> > /-- Joona Palaste ([EMAIL PROTECTED]) ------------- 
Finland --------\
> > \-------------------------------------------------------- 
rules! --------/
> > "'I' is the most beautiful word in the world."
> >    - John Nordberg
>
>





== 3 of 13 ==
Date:   Mon,   Oct 25 2004 11:26 am
From: Eric Sosman <[EMAIL PROTECTED]> 

zcraven wrote:
> when I type this line in class 'Club' I get the error 'club is not abstract
> and does not override abstract method compareTo':
> 
>     public class Club implements Comparable
> 
> I have been stuck on this for 4 hours!

    Did you implement a compareTo() method?  When
you said that your class "implements Comparable,"
you promised to provide compareTo().

-- 
[EMAIL PROTECTED]




== 4 of 13 ==
Date:   Mon,   Oct 25 2004 11:34 am
From: "zcraven" <[EMAIL PROTECTED]> 


"Carl Howells" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> zcraven wrote:
> > when I type this line in class 'Club' I get the error 'club is not
abstract
> > and does not override abstract method compareTo':
> >
> >     public class Club implements Comparable
> >
> > I have been stuck on this for 4 hours!
> >
> > Zac
> >
>
> Please don't top-post.
>
> You're getting that error because your class (class names should start
> with capital letters) is not declared as abstract, and doesn't override
> the abstract method compareTo.  The compiler is telling you quite
> clearly what's going on.
>
> In order to implement an interface in a non-abstract class, you have to
> provide implementations for the methods declared in the interface.
> Comparable happens to declare one method, named compareTo.  Check the
> documentation for Comparable to see what the method's exact signature
> should be, and what it should do when you implement it.

I am just a beginner to java and I dont really follow what you mean in your
2nd paragraph.  Basically I want to iterate all clubs in the league, getting
the number of points from each one and putting them into order.  When I try
to get a club from the arraylist, it says it requires an array when I am
using an arraylist.  Thanks.





== 5 of 13 ==
Date:   Mon,   Oct 25 2004 11:37 am
From: "zcraven" <[EMAIL PROTECTED]> 


"Eric Sosman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> zcraven wrote:
> > when I type this line in class 'Club' I get the error 'club is not
abstract
> > and does not override abstract method compareTo':
> >
> >     public class Club implements Comparable
> >
> > I have been stuck on this for 4 hours!
>
>     Did you implement a compareTo() method?  When
> you said that your class "implements Comparable,"
> you promised to provide compareTo().
>
> -- 
> [EMAIL PROTECTED]
>

The Club class should not abstract so it seems I cannot include the line
'implements Comparable'





== 6 of 13 ==
Date:   Mon,   Oct 25 2004 11:27 am
From: Andy Hill <[EMAIL PROTECTED]> 

"zcraven" <[EMAIL PROTECTED]> wrote:
>when I type this line in class 'Club' I get the error 'club is not abstract
>and does not override abstract method compareTo':
>
>    public class Club implements Comparable
>
>I have been stuck on this for 4 hours!
>
>Zac
>
If you implement the Comparable interface in Club, you gotta have a "public int
compareTo(Object o)" method in Club.   Lots of examples on the 'net on how best
to implement compareTo().




== 7 of 13 ==
Date:   Mon,   Oct 25 2004 11:41 am
From: "zcraven" <[EMAIL PROTECTED]> 


"zcraven" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Eric Sosman" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > zcraven wrote:
> > > when I type this line in class 'Club' I get the error 'club is not
> abstract
> > > and does not override abstract method compareTo':
> > >
> > >     public class Club implements Comparable
> > >
> > > I have been stuck on this for 4 hours!
> >
> >     Did you implement a compareTo() method?  When
> > you said that your class "implements Comparable,"
> > you promised to provide compareTo().
> >
> > -- 
> > [EMAIL PROTECTED]
> >
>
> The Club class should not abstract so it seems I cannot include the line
> 'implements Comparable'
>
>

How about I forget ArrayList and use a different method to display the
league instead?  I just need to access all the clubs, return the number of
points of each, sort these results, and then display them to the user.





== 8 of 13 ==
Date:   Mon,   Oct 25 2004 11:49 am
From: Steve Horsley <[EMAIL PROTECTED]> 

zcraven wrote:
> I need to sort a football league by the number of points each club has.  The
> clubs are objects stored in an ArrayList called 'league'.  Each club has a
> field for the number of points they have.
> 
> Can someone suggest the best way to sort this arraylist and output it to
> screen?
> 
> Most examples on the web suggest I type:
> 
>     collections.sort(league)
> 
> but i get the error that it expects an Array but has found an ArrayList.
> 
> PLEASE HELP! :-)
> 
> 

I suggest that you write an implementation of the Comparator class that 
goes something like (off the top of my head, not reading the docs):

public class ClubPointsComparator implements Comparator {
    public int compare(Object o1, Object o2) {
        Club c1 = (Club) o1;
        Club c2 = (Club) o2;
        return c2.points - c1.points;
    }
}

and then compare like this:

    Collections.sort(league, new ClubPointsComparator());


HTH
Steve




== 9 of 13 ==
Date:   Mon,   Oct 25 2004 11:55 am
From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> 

"zcraven" <[EMAIL PROTECTED]> writes:

>             Club club = league[i];    // ERROR 'array required but found

You cannot use array syntax for accessing List elements: Use get(i).



== 10 of 13 ==
Date:   Mon,   Oct 25 2004 12:41 pm
From: "sks" <[EMAIL PROTECTED]> 


"zcraven" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Carl Howells" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > zcraven wrote:
> > > when I type this line in class 'Club' I get the error 'club is not
> abstract
> > > and does not override abstract method compareTo':
> > >
> > >     public class Club implements Comparable
> > >
> > > I have been stuck on this for 4 hours!
> > >
> > > Zac
> > >
> >
> > Please don't top-post.
> >
> > You're getting that error because your class (class names should start
> > with capital letters) is not declared as abstract, and doesn't override
> > the abstract method compareTo.  The compiler is telling you quite
> > clearly what's going on.
> >
> > In order to implement an interface in a non-abstract class, you have to
> > provide implementations for the methods declared in the interface.
> > Comparable happens to declare one method, named compareTo.  Check the
> > documentation for Comparable to see what the method's exact signature
> > should be, and what it should do when you implement it.
>
> I am just a beginner to java and I dont really follow what you mean in
your
> 2nd paragraph.  Basically I want to iterate all clubs in the league,
getting
> the number of points from each one and putting them into order.  When I
try
> to get a club from the arraylist, it says it requires an array when I am
> using an arraylist.  Thanks.

What he's saying is, if you want your class to implement Comparable then you
have to 'complete' all the methods that the interface requires you to.
Comparable defines one method, public int compareTo(Object arg0), which you
have to put inside your class and write the code for in order to 'complete'
it. Then we say you've implemented the interface.





== 11 of 13 ==
Date:   Mon,   Oct 25 2004 12:54 pm
From: "zcraven" <[EMAIL PROTECTED]> 


"Steve Horsley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> zcraven wrote:
> > I need to sort a football league by the number of points each club has.
The
> > clubs are objects stored in an ArrayList called 'league'.  Each club has
a
> > field for the number of points they have.
> >
> > Can someone suggest the best way to sort this arraylist and output it to
> > screen?
> >
> > Most examples on the web suggest I type:
> >
> >     collections.sort(league)
> >
> > but i get the error that it expects an Array but has found an ArrayList.
> >
> > PLEASE HELP! :-)
> >
> >
>
> I suggest that you write an implementation of the Comparator class that
> goes something like (off the top of my head, not reading the docs):
>
> public class ClubPointsComparator implements Comparator {
>     public int compare(Object o1, Object o2) {
>         Club c1 = (Club) o1;
>         Club c2 = (Club) o2;
>         return c2.points - c1.points;
>     }
> }
>
> and then compare like this:
>
>     Collections.sort(league, new ClubPointsComparator());
>
>
> HTH
> Steve
>

THANK YOU - YOU ARE THE MAN!!!

It works perfectly now.  I read loads of stuff today about writing a
seperate class for the comparator but I couldnt work out how it linked to
the club class.  You explained it and now I can get on with my project - 5
hours after I got stuck on this bit.

Thanks again!

Zac





== 12 of 13 ==
Date:   Mon,   Oct 25 2004 12:08 pm
From: Oscar kind <[EMAIL PROTECTED]> 

In comp.lang.java.help zcraven <[EMAIL PROTECTED]> wrote:
> I need to sort a football league by the number of points each club has.  The
> clubs are objects stored in an ArrayList called 'league'.  Each club has a
> field for the number of points they have.
> 
> Can someone suggest the best way to sort this arraylist and output it to
> screen?

There are two good options:
1. Let a league implement Comparable is leagues are only compared/ranked
   according to their point
2. Create a Comparator<League> otherwise.

Read the API for the methods you need to implement (one in each case) to
compare two leagues with the points they have.


> Most examples on the web suggest I type:
> 
>    collections.sort(league)
> 
> but i get the error that it expects an Array but has found an ArrayList.

Get your case correct; they suggested Collections#sort(List): note the
capital C.

Their suggestion assumed option 1 above. If you chose option 2, use
Collections#sort(List<T>, Comparator<? super T>) instead.


-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2



== 13 of 13 ==
Date:   Mon,   Oct 25 2004 12:15 pm
From: Oscar kind <[EMAIL PROTECTED]> 

In comp.lang.java.help zcraven <[EMAIL PROTECTED]> wrote:
> This is the whole code of the method I am writing:
> 
> public void printLeagueTable()
>    {
>        System.out.println("LEAGUE: " + leagueName);
>        Collections.sort(league);
> 
>        for (int i=0; i<league.size(); i++)
>        {
>            Club club = league[i];    // ERROR 'array required but found
> arraylist'

Yes, league appearently is an array (!) of Club's. Not an ArrayList...


>            String clubName = club.getClubName();
>            int points = club.getPointsTally();
>            System.out.println(clubName + " = " + points);
>        }
>    }
> 
> (the clubs in the league have other fields but I want to sort them by the
> goalTally field)

For this implementation, create a Comparator instead of implementing
Comparable (the method you need to implement does approximately the same).
Also, get this URL in your bookmarks if you haven't already:
        http://java.sun.com/j2se/1.5.0/docs/api/

The URL contains the Java API, and tells you what your building blocks
are.


> I have been stuck on this for 4 hours!

I hate to break it to you, but that's because you were not accurate in
your original problem description, and failed to read the API.

If you did, you could also have spent 4 hours on it, but you'd have solved
it by now.


-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2




==========================================================================
TOPIC: How tom create a NEW class online
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1552191b47783f48
==========================================================================

== 1 of 2 ==
Date:   Mon,   Oct 25 2004 11:41 am
From: [EMAIL PROTECTED] (Alexander) 

Here is my problem:
 I need to create a NEW class online, during code execution. A class
with members only (no methods), but one that inherits base class or
implements empty interface.
 There is no neither *.class file nor *.java (text) file.
 This is a part of my thesis, so work around is not an option (at
least not to create text file with java code and compile). I thought
that a reflection can help me, but nothing helpfull was found.
How can I do this? (or at least if this is impossible – tell me )

Thanks



== 2 of 2 ==
Date:   Mon,   Oct 25 2004 1:08 pm
From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> 

[EMAIL PROTECTED] (Alexander) writes:

>  This is a part of my thesis, so work around is not an option (at
> least not to create text file with java code and compile). I thought
> that a reflection can help me, but nothing helpfull was found.

Reflection is for analysing and using existing classes. You want to
synthesize a class, there are tools/APIs for that, though I cannot
remember any at the moment.




==========================================================================
TOPIC: Making multiple HTTP requests using same HttpConnection object in j2me
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/262c1d5fa2776e3
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 11:50 am
From: [EMAIL PROTECTED] (Ravi Ambros Wallau) 

Hi:
  I'm developing an application that should make a serie of requests,
using the POST method and transfering binary data, to our HTTP server.
  If I use the method Connector.open(url), and then call the methods
openDataOutputStream() and openDataInputStream, everything works fine.
But, when making multiple calls, I'm sure that this is not the best
way to do that.
  I've tryed to use the keep-alive feature of http connections, but I
really can't figure how. I've tryed something like this:

  HttpConnection hc = (HttpConnection)Connector.open(url);
  ... set headers
  DataOutputStream out = hc.openDataOutputStream();
  out.write(...);
  out.flush();
  out.close();
  DataInputStream in = hc.openDataInputStream();
  in.read(); 

  ... Cycle is finalized - now, if I make this:
  out.write(...);
  out.flush();
  out.close();

  ... or this:
  out = hc.openDataOutputStream();

  I receive an IOException with the message "Connection is already
open".
  I'm looking for some help on Internet (using google), but there are
few articles about the topics I'm searching for.
  
  Thanks,
    Ravi.




==========================================================================
TOPIC: 1.5, rtf & word
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50f7a7e4797096a9
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 11:54 am
From: [EMAIL PROTECTED] (Jared MacDonald) 

"Ike" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Does anyone know if the RTFEditorKit in 1.5 now handles recent MS Word
> RTF-type files, or is it still as it was with 1.4.2 ? Thanks, Ike

They did fix the Word 2002/2003 crashing bug in 1.5 -- 

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042109

The RTF package, however, still majorly blows chunks, as it were.

Jared




==========================================================================
TOPIC: unfindable statement-exception
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ccc76dd893bc29a1
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:01 pm
From: "pet0etie" <[EMAIL PROTECTED]> 

heyn

i have an awkward error on a JSP-page but i can't see where the error might
be ..
here u will find the different statements i use on my JSP-page
which command can generate me a java.io.CharConversionException : isHexDigit
?

String[] reqArray = request.getParameterValues("xyz");
String name = request.getParameter("name");
String logurl = Constants.LOG_URL;
Date datum = new Date();
String dateS =  new DecimalFormat("00").format(datum.getYear()-100);
Class.forName(Constants.DB_CLASS);
Connection connN =
DriverManager.getConnection(Constants.DB_DRIVER,Constants.DB_USER,Constants.
DB_PASSW);
Statement stmtN = connN.createStatement();
ResultSet rsltN = stmtN.executeQuery("select * from names where name='" +
name + "'");
if ( rsltN.next() ) {
int newsgrpid = rsltN.getInt("id");
stmtN.close();
connN.close();
reqArray[i] = URLDecoder.decode(reqArray[i]);
String[] toks = reqArray[i].split("°");
if ( toks != null ) {
if ( toks[0] != null ) {
if ( toks[0].equals("XXXX") ) {
if ( toks.length == 3 ) {
int art = Integer.parseInt(toks[2]);

as far as i can't see ... i can't find any command who might throw such
exception
does anyone can help me ?

i must say ... the data is send from a java-application with :

      uitW3.println("POST " + urlJ2W + " HTTP/1.0");
      uitW3.println("Host: " + hostW + ":" + portW );
      uitW3.println("Content-type: text/html");
      uitW3.println("Content-Length: " + names.length() );
      uitW3.println();
      uitW3.println(names);
      uitW3.println();

i already tried with url-de/en-coding a both sides (JSP and java) but
nothing worked out yet

a "thank you" in advance

pet0etie









==========================================================================
TOPIC: Mixing EJB 1.1 remote and 2.0 local beans within a transaction...
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3bff8d99f36b1ee6
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:05 pm
From: [EMAIL PROTECTED] (Chris S) 

We are currently upgrading our EJB modules from 1.1 to 2.0 local.  We
have a repository structure like the following in front of the entity
beans:

SessionRepository
calls on
TopicRepository

The SessionRepository only has JDBC calls into our database using a
1.1 compliant connection in WebSphere (v4 for those that use the DB2
data source).  The TopicRepository uses a local entity EJB which gets
2.0 compliant connections (v5 DB2 data source) from WebSphere.  Each
version of the data source has a different JNDI binding such as
"jdbc/DB2CONN4" and "jdbc/DB2CONN5".  On the TopicLocal EJB which is
used from the TopicRepository, the "trans-attribute" tag for the
container-transaction uses "RequiresNew".  I thought that this would
allow for the full transaction to work across the mixed EJB
compliance.

Could somebody help me with a way to make this work?  Are there more
file descriptor modifications to make?  Is it possible to mix
compliance within an application function area?




==========================================================================
TOPIC: Logging configuration file w/ web start
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/647b28fc11be9145
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 11:11 am
From: Oscar kind <[EMAIL PROTECTED]> 

Tobias Besch <[EMAIL PROTECTED]> wrote:
> Oscar kind wrote in news:[EMAIL PROTECTED]:
>> I generally prefer to locate the log4j configuration file myself, and
>> feed it to log4j...
> 
> Could you please tell me how you do this?
> 
> BTW: I don't use log4j. I use java.util.logging.

I place log4j.properties in the default package,  i.e. in the root of
the .jar file. I also use the following LogFactory (package statement
stripped):

===== begin code =====
mport org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.commons.logging.impl.LogFactoryImpl;
import org.apache.log4j.PropertyConfigurator;


/**
 * @author <a href="mailto:[EMAIL PROTECTED]">Oscar Kind</a>
 * @version $Id: LogFactory.java,v 1.1 2004/10/04 14:27:54 oscar Exp $
 */
public class LogFactory
{
        /**
         * Logging factory.
         */
        private static final org.apache.commons.logging.LogFactory LOG_FACTORY =
                new LogFactoryImpl();

        /**
         * Static initializer that initializes the LOG_FACTORY above.
         */
        static
        {
                LOG_FACTORY.setAttribute(
                        LogFactoryImpl.LOG_PROPERTY,
                        Log4JLogger.class.getName());
                PropertyConfigurator.configure(
                        LogFactory.class.getResource("/log4j.properties"));
        }


        /**
         * Private, empty constructor: this is a utility class.
         */
        private LogFactory()
        {
                // Empty
        }


        /**
         * Get a logger for the specified class.
         *
         * @param clazz the class to get a logger for.
         * @return a logger
         */
        public static Log getLogger(Class clazz)
        {
                return LOG_FACTORY.getInstance(clazz);
        }
}
====== end code ======


-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2




==========================================================================
TOPIC: c:url param encoding problem: £ (UK currency symbol)
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6fa3c5d551e4916a
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:10 pm
From: [EMAIL PROTECTED] (Brian Dobby) 

Thanks for the reply, and sorry for the delay in resuming this thread.

Using &pound; doesn't help: I still get the problem. Even worse, it
occurs on user input. If I have a form that contains the following:
<textarea name=text1>${param.text1}</textarea>
and enter £1, when the form is redisplayed there is one garbage
character preceding the '£'. If I submit the form again, there are two
more (different) garbage characters preceding the first. It's like the
characters are being converted to a double-byte notation (the JVM's
unicode?) and not converted back.

Anyone any ideas?
  TIA
    Brian



Paul Lutus <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Brian Dobby wrote:
> 
> > Hi, can anyone explain what's going on here?
> > 
> > I have a jsp which contains a <c:url> tag with a <c:param> tag. If the
> > value of the c:param contains £ (0xa3, the UK currency symbol, in case
> > it doesn't display in your browser...), the encoded value in the
> > generated HTML appears as %c2%a3. If the value is passed to a
> > subsequent page, then passed back, it appears as %c2%a3%c2%a3.
> > 
> > The app is running on Tomcat 5 under Windows in the UK. No special
> > encoding is requested anywhere (e.g. jsp page directive).
> 
> A typical browser cannot be expected to reliably render a symbol that is
> outside the old-style ASCII 7-bit character set. This can be dealt with in
> any number of ways, most problematical or erratic, but it is much better to
> emit the appropriate HTML character entity --
> 
> &pound;
> 
> -- which, by virtue of having been composed entirely of ASCII 7-bit
> characters, will display properly on most browsers.
> 
> Also, the value you specify (0xa3) is not the UK currency symbol in all
> character sets. The fact that it displays correctly in some cases is a
> matter of luck. Relying on a character constant > 128 is just asking for
> trouble.




==========================================================================
TOPIC: applet's call comportement
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc1d4563dc67060c
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:12 pm
From: Paul Lutus <[EMAIL PROTECTED]> 

Emmanuel Freund wrote:

> Hi, I'm currently developping a web browser in java and I'd like to have
> the windows openned by some applets to be displayed in my own workspace

Define "workspace". Leave nothing to the imagination.

> and not the OS's one. If anybody have an idea, some clue, whatever, it
> would be of great help.
> 

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





==========================================================================
TOPIC: help with my first project on first job, how to read a strange file, thanks a 
lot!!!!!!!
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8c32ba1a17d68c9a
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:15 pm
From: [EMAIL PROTECTED] (Alex Kizub) 

I just wonder why people are not tired to reinvent the wheel.
There are so much good log analyzers...

Here you are:

import java.io.*;
public class LogAnalyzer {

        public static void main(String[] args) throws Exception {
                System.out.println("LogAnalyser starts");

                File logFile=new File("abc.log");
                long seek,lastModified;
                seek=lastModified=0;
                
                RandomAccessFile ra=new RandomAccessFile(logFile,"r");
                String rez;
                
                while((rez=ra.readLine())!=null){
                        System.out.println(rez);
                        seek=ra.getFilePointer();
                }
                ra.close();
                lastModified=logFile.lastModified(); 
                
                int step=200;
                while (--step>0){
                        Thread.sleep(1000);
                        if (lastModified!=logFile.lastModified()){
                                ra=new RandomAccessFile(logFile,"r");
                                ra.seek(seek);
                                while((rez=ra.readLine())!=null){
                                        System.out.println("added="+rez);
                                        seek=ra.getFilePointer();
                                }
                                ra.close();
                                lastModified=logFile.lastModified(); 
                        }
                }

                System.out.println("LogAnalyser ends");
        }
}


I hope you know what to do with String except to print it.
Alex Kizub.

[EMAIL PROTECTED] (matt) wrote in message news:<[EMAIL PROTECTED]>...
> the OS is mainly windows. i doubt windows has powerful tool to do the
> job automatically.
> i need to open and close the file frequently because another process
> is writing to the file. then Java create a new object each time I open
> the file. in this case, can the program remeber the position I set
> last time?
> if yes, can i do the same thing with BufferedReader class instead of
> RandomAccessFile. i am not sure whether RandomAccessFile can easily
> allow me to keep the new line characters and white space among the
> valid text. i need these chars in the application. The length() can
> not help me a lot, since the file size does not change when new text
> is written into the file. the new text write over the whitespace but
> do not change the file size.
> thanks again!
> Alex Kizub <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> > You didn't mention OS. Probably it could be solved only by OS tools.
> > For example for UNIX like it could be grep, tail -f, awk... |, >
> > 
> > Java has other features, but since you can't change application and should
> > only change the file (which is not good solution itself) here are some
> > solutions for you.
> > 
> > Use java.io.RandomAccessFile.
> > So you can set position which you alreadu reached with method seek, you
> > can know length of new open file with method
> > length().
> > Then, I suggest, read file with method read(byte[] b) copy none white
> > spaces to another array and write it to the new file.
> > Pretty easy.
> > 
> > BTW. With java.io.File you can understand last modification time and
> > decide do you need reread file again.
> > 
> > Good luck in your new job.
> > Alex Kizub.
> > matt wrote:
> > 
> > > Java guys:
> > > this is my first project at my first job. so pls help if you could.
> > > i am working with a text file with strange format. The file has a lot
> > > of white space between the last line of valid text and  the end of
> > > file character. And the file is update frequently. New valid text is
> > > appended behind the original valid text and overwrite some whitespace.
> > >  I need to feed this file as an input to an application. but this
> > > application only take files without such whitespace. The application
> > > need to read the file frequently to see whether new text is appended.
> > > if there is, get the appended text.
> > > My initial solution is to convert the original file into a new file in
> > > which the whitespace is truncated. then the application can read the
> > > new file.
> > > possibility 1:
> > >  loop
> > >    read 1 line of text of original file
> > >    write this line to new file
> > >  until read the long line of white space
> > >  close both file
> > >
> > > in this case, what class and method should i use, especially in
> > > examing the white spaces?
> > >
> > > possibility 2:
> > >  the previous one is not smart because the same text is read and write
> > > each time when the file is read. so is there a way i can just each
> > > time check whether update happens to the file and then just write the
> > > update to the new file? such as in C, a file pointer know the position
> > > of last read. can i do the same in Java or C#? or other ways to do it?
> > > possibility 3:
> > >  very unlikely but smarter,
> > >    read the file in a stream, truncate the whitespace inside the
> > > stream, then feed the stream directly into the application. but it is
> > > unlikely because i can not change the souce code the application.
> > >
> > > any other possibilies to solve this problem?
> > > for all the possibilities, pls tell me what class and method should i
> > > use, sample code and website is extremely helpful.
> > > thanks a lot!!!!!




==========================================================================
TOPIC: Multi Struts App Challenge
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b1ce0ed49d4d32ca
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:35 pm
From: [EMAIL PROTECTED] (bint1377) 

Hi 

We are building an intranet application which is spread across
multiple applications and multi modules within an application.

I was wondering if someone can show me as to how can we can an action
from one application to another one.

That is from jsp in App1 ,I want to call an action which is defined in
struts config of moduleB in App2
Any thought would be appreciated




==========================================================================
TOPIC: How can I convert a String to an Int?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3a44aee4d751e576
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:36 pm
From: "Madhur Ahuja" <[EMAIL PROTECTED]> 

John Smith <[EMAIL PROTECTED]> wrote:
> Hi Java-Coder!
>
> I'am coding in Java for about an half year, but I still don't know
> how I convert a String to a Int.
> Can you help me?

String piStr1 = "3";
int pi1 = Integer.valueOf(piStr).intValue();


--
Madhur Ahuja [madhur<underscore>ahuja<at>yahoo<dot>com]

Homepage
http://madhur.netfirms.com










==========================================================================
TOPIC: Generating the proper url
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e91af77a00eb79b2
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 12:53 pm
From: [EMAIL PROTECTED] (D. Alvarado) 

Hello,
   I am running WebLogic 5.1 sp12 on Solaris, JDK 1.3.  Currently mthe
primary url to access the document root is something like:

http://12.4.8.16:8000/

On the index page, I have a link

<a href='/mydir/'>My Dir</a>

but the url that appears in the status bar (and indeed when I click
the link) is http://12.4.4.16/mydir/ and leaves out the port 8000. 
How would I dynamically generate a link in JSP for the href to get the
proper url?

Thanks in advance, -  Dave




==========================================================================
TOPIC: Challenge: Triangles puzzle
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5e013ca5d7daa5f0
==========================================================================

== 1 of 1 ==
Date:   Mon,   Oct 25 2004 1:05 pm
From: Frank Buss <[EMAIL PROTECTED]> 

Frank Buss <[EMAIL PROTECTED]> wrote:

> I've setup a challenge, mainly for C++, Java and Lisp, but every other 
> language is welcome:
> 
> http://www.frank-buss.de/challenge/index.html

the challenge is over, thanks to all participants. I've submitted the link 
at Slashdot, too, there are always so objective discussions :-) 

-- 
Frank Buß, [EMAIL PROTECTED]
http://www.frank-buss.de, http://www.it4-systems.de



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

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

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 

Reply via email to