Hi Abderrahim,
I use this:
using GLib;
public static void main(string[] args)
{
string contents;
try {
FileUtils.get_contents("test.txt", out contents);
} catch (FileError err) {
stdout.printf("error");
}
var info = contents.str("[INFO]");
if (info != null) {
var needed_text = info.substring("[INFO]".length);
stdout.printf("%s", needed_text);
}
}
and it works perfectly.
Thank you so much !
Nicolas.
Hi,
2009/9/3 Nicolas <c.r....@wanadoo.fr>:
That's the problem, I have a text file, but at a certain place there is, for
example, the code [INFO] and I need to read everything that comes after this
code, which in fact is just text !
Maybe you just want FileUtils.get_contents [1], it will return a
string that you can use as you like
string contents;
try {
FileUtils.get_contents(filename, out contents);
} catch (FileError) {
//handle appropriately
}
var info = contents.str('[INFO]');
if (info != null) {
var needed_text = info.substring('[INFO]'.length);
// do what you want with this
}
I haven't compiled this code, so there may be some problems with it,
but the idea is there.
HTH,
Abderrahim
[1] http://references.valadoc.org/glib-2.0/GLib.FileUtils.get_contents.html
_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list