Using java Syntax Highlighting
- lsSagor = "some text\n Some more text\n More text~Text again\n Text\n text~Some text ..."
- final String[] laList = lsSagor.split("~");
- String[] laSaga = laList[0].split("\n");
Parsed in 0.011 seconds, using GeSHi 1.0.8.4
Gives:
laSaga[0] => some text
laSaga[1] => some more text
laSaga[2] => More text
But if I download the textfile, it fails to split and gives:
laSaga[0] => "some text\n Some more text\n More text"
So it seems the first split works, but not the second.
There is the code I use to download the file
Using java Syntax Highlighting
- String lsSagor = getFileFromUrl(BASEURL+"/sagor.txt");
Parsed in 0.010 seconds, using GeSHi 1.0.8.4
Using java Syntax Highlighting
- public static String getFileFromUrl(String url)
- {
- InputStream content = null;
- try
- {
- HttpGet httpGet = new HttpGet(url);
- HttpClient httpclient = new DefaultHttpClient();
- // Execute HTTP Get Request
- HttpResponse response = httpclient.execute(httpGet);
- content = response.getEntity().getContent();
- }
- catch (Exception e)
- {
- //handle the exception !
- }
- BufferedReader rd = new BufferedReader(new InputStreamReader(content), 4096);
- String line;
- StringBuilder sb = new StringBuilder();
- try {
- while ((line = rd.readLine()) != null) {
- sb.append(line);
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- rd.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return sb.toString();
- }
Parsed in 0.012 seconds, using GeSHi 1.0.8.4