This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Another newbie question

3 replies
Pedro Pastor
Joined: 2009-12-11,
User offline. Last seen 42 years 45 weeks ago.
Hello all,

Is there any way of doing in Scala something similar as the functionality provided by the Java classes: "Scanner" and "StreamTokenizer"??

Regards,
Pedro
Kevin Wright
Joined: 2009-06-09,
User offline. Last seen 49 weeks 4 days ago.
Re: Another newbie question
What are you trying to do exactly?
A functional approach using for/yield or map/flatmap/filter would probably be better...

On Sat, Dec 12, 2009 at 5:52 PM, Pedro Pastor <ppsppg@gmail.com> wrote:
Hello all,

Is there any way of doing in Scala something similar as the functionality provided by the Java classes: "Scanner" and "StreamTokenizer"??

Regards,
Pedro

Pedro Pastor
Joined: 2009-12-11,
User offline. Last seen 42 years 45 weeks ago.
Re: Another newbie question
Hi Kevin. Thanks for your interest on this question.

I'm trying to translate some Java packages to Scala for practicing reasons. If it works OK (if I manage to succeed with Scala ;-), I'll migrate the whole Java application to Scala.

At present, the task is performing data conversion from formated (using different data types) text input files to XML (output file).

From answers received to a previous message, I'll keep the File-IO part of the code in Java.

Once I get the "data stream" from input-file, I need to "analyze" the data read ("tokenize" the stream, read each token according to its source type and asign the result to some XML structure).

Now the question is:
Could I begin using Scala in order to "analyze" the data read from files, or I still have to stick to Java using "StreamTokenizer" class (for example) for this purpose??

Regards.
Pedro

2009/12/12 Kevin Wright <kev.lee.wright@googlemail.com>
What are you trying to do exactly?
A functional approach using for/yield or map/flatmap/filter would probably be better...

On Sat, Dec 12, 2009 at 5:52 PM, Pedro Pastor <ppsppg@gmail.com> wrote:
Hello all,

Is there any way of doing in Scala something similar as the functionality provided by the Java classes: "Scanner" and "StreamTokenizer"??

Regards,
Pedro


David Hall 4
Joined: 2009-08-21,
User offline. Last seen 42 years 45 weeks ago.
Re: Another newbie question

On Sat, Dec 12, 2009 at 4:01 PM, Pedro Pastor wrote:
>
> Once I get the "data stream" from input-file, I need to "analyze" the data
> read ("tokenize" the stream, read each token according to its source type
> and asign the result to some XML structure).
>
> Now the question is:
> Could I begin using Scala in order to "analyze" the data read from files, or
> I still have to stick to Java using "StreamTokenizer" class (for example)
> for this purpose??

Take a look at Scala's parser combinator libraries. In particular:
http://www.scala-lang.org/docu/files/api/scala/util/parsing/combinator/l...

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland