Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > any LWP::UserAgent equivalent in java && a java regex question

Reply
Thread Tools

any LWP::UserAgent equivalent in java && a java regex question

 
 
z.m_wu@att.net
Guest
Posts: n/a
 
      03-16-2008
Hi All

I have found Perl's LWP::UserAgent and related packages useful. Does
java have any thing
equivalent i.e. that won't make me do encoding when I want to do an
http POST? I am a newbie
to java. Also, is there anything like java CPAN ?

Also, in perl, if I do /some pattern (some other pattern)/ I get "some
other pattern" in $1. I found
out that () have different meanings in Java. The only to get $1 in
Java is to write more lines.

Thanks in advance

Z. M. Wu
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      03-16-2008
wrote:
> I have found Perl's LWP::UserAgent and related packages useful. Does
> java have any thing
> equivalent i.e. that won't make me do encoding when I want to do an
> http POST? I am a newbie
> to java. Also, is there anything like java CPAN ?


I think Jakarta Commons HttpClient is what you want.

> Also, in perl, if I do /some pattern (some other pattern)/ I get "some
> other pattern" in $1. I found
> out that () have different meanings in Java. The only to get $1 in
> Java is to write more lines.


Java regex support groups. The Java code to use regex is different
than Perl, but that is to be expected.

Arne
 
Reply With Quote
 
 
 
 
z.m_wu@att.net
Guest
Posts: n/a
 
      03-16-2008
On Mar 15, 8:57 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
> z.m...@att.net wrote:
>
> Java regex support groups. The Java code to use regex is different
> than Perl, but that is to be expected.
>
> Arne


Thanks. I have figured it out.

Another question. Is there any java equivalent of Perl hash/db
files? I want
to store a few pieces of data on the disk.

z.m.wu
 
Reply With Quote
 
Logan Shaw
Guest
Posts: n/a
 
      03-16-2008
wrote:
> Another question. Is there any java equivalent of Perl hash/db
> files? I want
> to store a few pieces of data on the disk.


If you really want literal Berkeley DB, apparently there is a
Java port of it (maintained by Oracle, the same people who now
maintain the regular/original Berkeley DB):

http://www.oracle.com/technology/pro.../je/index.html

I have never tried it out and don't know how mature it is, but
it might be worth a look.


More generally, I would say Berkeley DB is a good solution if
your goal is to manipulate a subset of a large amount of data
(and you don't want to or can't load it all into RAM), but it
probably isn't the best solution for everything. There are
other technologies out there for Java that assist you with
loading and storing data. For example, you can serialize objects
to/from XML. One of these technologies might allow you to store
a more convenient data structure that the key/value pairs that
Berkeley DB allows for. If you give more specifics about what
you're trying to accomplish, maybe somebody can recommend one.

- Logan
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-16-2008
Logan Shaw wrote:
> wrote:
>> Another question. Is there any java equivalent of Perl hash/db
>> files? I want
>> to store a few pieces of data on the disk.

>
> If you really want literal Berkeley DB, apparently there is a
> Java port of it (maintained by Oracle, the same people who now
> maintain the regular/original Berkeley DB):
>
> http://www.oracle.com/technology/pro.../je/index.html
>
> I have never tried it out and don't know how mature it is, but
> it might be worth a look.
>
>
> More generally, I would say Berkeley DB is a good solution if
> your goal is to manipulate a subset of a large amount of data
> (and you don't want to or can't load it all into RAM), but it
> probably isn't the best solution for everything. There are
> other technologies out there for Java that assist you with
> loading and storing data. For example, you can serialize objects
> to/from XML. One of these technologies might allow you to store
> a more convenient data structure that the key/value pairs that
> Berkeley DB allows for. If you give more specifics about what
> you're trying to accomplish, maybe somebody can recommend one.


The Derby database, a.k.a. the "Java DB", comes with Java 6 and above.
PostgreSQL www.postgresql.org is an excellent choice, also. These are full,
(mostly-)SQL-compliant DBMSes.

The java.util.Properties class directly supports name-value pair serialization
to either a simple "name=value" text file or to XML.

HashMap (and other Map implementations) can be serialized using
java.io.Serializable conventions or other mechanisms.

--
Lew
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      03-16-2008
wrote:
> On Mar 15, 8:57 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
>> z.m...@att.net wrote:
>>
>> Java regex support groups. The Java code to use regex is different
>> than Perl, but that is to be expected.


> Another question. Is there any java equivalent of Perl hash/db
> files? I want
> to store a few pieces of data on the disk.


In Java you would typical use a database through the standard
JDBC interface.

Arne
 
Reply With Quote
 
Logan Shaw
Guest
Posts: n/a
 
      03-17-2008
Arne Vajhøj wrote:
> wrote:
>> On Mar 15, 8:57 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
>>> z.m...@att.net wrote:
>>>
>>> Java regex support groups. The Java code to use regex is different
>>> than Perl, but that is to be expected.

>
>> Another question. Is there any java equivalent of Perl hash/db
>> files? I want
>> to store a few pieces of data on the disk.

>
> In Java you would typical use a database through the standard
> JDBC interface.


This is not quite (or at least usually is not) equivalent
functionality. With JDBC, you typically do not have control
over where the data files are written, but with Berkeley DB,
you do. (Of course, there are some relational databases
where you can create a new instance easily and you do have
control, but not in many cases.)

Whether the original poster needs that is an unknown, though.

- Logan
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      03-17-2008
Logan Shaw wrote:
> Arne Vajhøj wrote:
>> wrote:
>>> On Mar 15, 8:57 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
>>>> z.m...@att.net wrote:
>>>> Java regex support groups. The Java code to use regex is different
>>>> than Perl, but that is to be expected.

>>
>>> Another question. Is there any java equivalent of Perl hash/db
>>> files? I want
>>> to store a few pieces of data on the disk.

>>
>> In Java you would typical use a database through the standard
>> JDBC interface.

>
> This is not quite (or at least usually is not) equivalent
> functionality. With JDBC, you typically do not have control
> over where the data files are written, but with Berkeley DB,
> you do. (Of course, there are some relational databases
> where you can create a new instance easily and you do have
> control, but not in many cases.)
>
> Whether the original poster needs that is an unknown, though.


There are plenty of databases where you can specify location
of files. All the embedded ones.

The JDBC API is much different from BDB (at least that is
my impression - I have not worked with BDB myself).

But the tradition in the Java world is to use JDBC and
not any special API's.

It is usually a bad practice to try and move 1:1 from one
language to another.

Coding Java in Java and Perl in Perl is better than Java in Perl
and Perl in Java.

Arne
 
Reply With Quote
 
z.m_wu@att.net
Guest
Posts: n/a
 
      03-17-2008
On Mar 16, 9:14 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
>
> There are plenty of databases where you can specify location
> of files. All the embedded ones.
>
> The JDBC API is much different from BDB (at least that is
> my impression - I have not worked with BDB myself).
>
> But the tradition in the Java world is to use JDBC and
> not any special API's.
>


Hi

The program I am writing is a small desktop app which
will be distributed to users who most likely won't have
access to a sql server. My need is just a few
key value pairs stored on disk to store the state of
the program/data. A sql server seems an overkill for this purpose.

Are you saying I can somehow use jdbc api to use some files
on disk?

Thanks

z.m.wu
 
Reply With Quote
 
Patricia Shanahan
Guest
Posts: n/a
 
      03-17-2008
wrote:
> On Mar 16, 9:14 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
>> There are plenty of databases where you can specify location
>> of files. All the embedded ones.
>>
>> The JDBC API is much different from BDB (at least that is
>> my impression - I have not worked with BDB myself).
>>
>> But the tradition in the Java world is to use JDBC and
>> not any special API's.
>>

>
> Hi
>
> The program I am writing is a small desktop app which
> will be distributed to users who most likely won't have
> access to a sql server. My need is just a few
> key value pairs stored on disk to store the state of
> the program/data. A sql server seems an overkill for this purpose.

....

Have you looked at java.util.Properties?

Patricia
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
regex that is equivalent to perl's syntax Lee Sander Python 2 11-12-2007 03:51 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
Java regex imposture re: Perl regex compatibility a_c_Attlee@yahoo.com Java 2 05-06-2005 12:16 AM
perl regex to java regex Rick Venter Java 5 11-06-2003 10:55 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57