Joao Luis <[email protected]> wrote on 04/26/2009 08:13:22 AM:

> Hello.
> 
> I've been working with X10 for a college class and I'm supposed to 
implement
> a given algorithm. Though, it would be great to be able to read data 
from a
> file, or even stdin, and output them.
> 
> I'm quite able to output data using x10.io.Console, but it seems 
impossible
> to read data from a file or stdin; of course I'm assuming I'm 
completelly
> wrong, but I don't seem to find any evidence on the contrary.
> 
> I'm using X10 version 1.7.

Hi, Joao,

How exactly are you reading the input?  I've just tried the following:

public class IOTest {
  public static def main(Rail[String]) {
    try {
      val s = x10.io.Console.IN.readLine();
      x10.io.Console.OUT.println(s);
    } catch (x10.io.IOException) { }
  }
}

and it worked perfectly.  Another recommended usage (from x10.io.Reader) 
is

try {
   val input = new File(inputFileName);
   val output = new File(outputFileName);
   val i = input.openRead();
   val p = output.printer();
   for (line in i.lines()) {
      line = line.chop();
      p.println(line);
   }
} catch (IOException) { }

What is the problem you're encountering?
        Igor
-- 
Igor Peshansky  (note the spelling change!)
IBM T.J. Watson Research Center
XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/)
X10: Parallel Productivity and Performance (http://x10.sf.net/)


------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to