System.getProperty("line.separator") replacement/equivalent?

518 views
Skip to first unread message

darkflame

unread,
Aug 6, 2010, 11:18:05 AM8/6/10
to Google Web Toolkit
I wish to find the indexOf a new line in a large string and not sure
how to do it in a cross-platform way neatly.
I'll be iterating over the string doing this a lot, so I'd rather use
a "proper" method rather then hacking something together.

Normally I could use "System.getProperty("line.separator") " to
identify the character needed, and then just use that in the indexOf
statement. But that doesn't compile under gwt, so does anyone know a
good alternative method?

Cheers,
Thomas :)

dolc...@gmail.com

unread,
Aug 6, 2010, 3:42:24 PM8/6/10
to Google Web Toolkit
You do know that GWT runs in the browser right? I think you're trying
to find out if a file is new lined with \r\n or \n, then i would
detect it on the server and either translate it or make a way to
return the information to the browser (RPC?).

darkflame

unread,
Aug 6, 2010, 4:02:29 PM8/6/10
to Google Web Toolkit
yes, theres a static text file on the server I wish to read in and
detect the lines from.
A simple requestBuilder is used to retrieve it.

Are you saying I should use a php script to first parse over the text
file, then echo out what it uses?
Doesn't seem very quick or neat.

I've got a text file...which could have been created on anything.
And I simply want to read over it detecting the lines in the most
efficient way.

At the moment I'm doing it with;

int newlineloc = IncomingScriptFile.indexOf("\r",pos);
int newlineloc2 = IncomingScriptFile.indexOf("\n",pos);
newlineloc = (newlineloc<newlineloc2)?newlineloc:newlineloc2;

Which doesn't seem too neat, and I'm not sure it deals with all
possibilities.

Thomas Jackson

unread,
Aug 6, 2010, 4:06:10 PM8/6/10
to google-we...@googlegroups.com
Have you considered writing a GWT Service that allows you to pass the filename and then returns a List of Strings?  You can open a FileStream on the server and then read line by line and let it handle it and not have to worry about newlines on the browser.

Just a thought...



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Thomas Wrobel

unread,
Aug 6, 2010, 4:12:25 PM8/6/10
to google-we...@googlegroups.com
Nice idea, but unfortunately my server doesn't support servlet's,
which limits me somewhat :)
Reply all
Reply to author
Forward
0 new messages