Changeset 12473
- Timestamp:
- 2006-08-18T09:48:32+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r12050 r12473 395 395 return stripped_string_buffer.toString(); 396 396 } 397 398 /////////////////////////////kk added//////////////////////// 399 400 static public StringBuffer readXMLStream(InputStream input_stream) 401 { 402 StringBuffer xml = new StringBuffer(""); 403 404 try { 405 InputStreamReader isr = new InputStreamReader(input_stream, "UTF-8"); 406 BufferedReader buffered_in = new BufferedReader(isr); 407 408 String line = ""; 409 boolean xml_content = false; 410 while((line = buffered_in.readLine()) != null) { 411 if(xml_content) { 412 xml.append(line); 413 xml.append("\n"); 414 } 415 else if(line.trim().startsWith("<?xml")) { 416 xml_content = true; 417 xml.append(line); 418 xml.append("\n"); 419 } 420 } 421 buffered_in = null; 422 } 423 catch (Exception error) { 424 System.err.println("Failed when trying to parse XML stream"); 425 error.printStackTrace(); 426 } 427 428 return xml; 429 } 430 431 /** Builds the cache dir by appending the user path and 'cache'. 432 * @return a File representing the path to the private file cache within the current collection. 433 */ 434 public static File getCacheDir() { 435 return new File(getGLIUserFolder(), StaticStrings.CACHE_FOLDER); 436 } 437 438 /** Method which constructs the log directory given a certain collection. 439 * @param col_dir The location of the collection directory as a <strong>String</strong>. 440 * @return The location of the given collections log directory, also as a <strong>String</strong>. 441 */ 442 public static String getLogDir(String col_dir) { 443 if(col_dir != null) { 444 return col_dir + LOG_DIR; 445 } 446 else { 447 return getGLIUserFolder().getAbsolutePath() + File.separator + LOG_DIR; 448 } 449 } 450 451 static final private String APPLICATION_DATA_FOLDER = "Application Data"; 452 static final private String UNIX_GLI_CONFIG_FOLDER = ".gli"; 453 static final private String USER_HOME_PROPERTY = "user.home"; 454 static final private String WIN_GLI_CONFIG_FOLDER = "Greenstone" + File.separator + "GLI"; 455 /** Definition of an important directory name, in this case the log directory for the collection. */ 456 static final public String LOG_DIR = "log" + File.separator; 457 458 static public File getGLIUserFolder() 459 { 460 if (Utility.isWindows()) { 461 return new File(System.getProperty(USER_HOME_PROPERTY) + File.separator + APPLICATION_DATA_FOLDER + File.separator + WIN_GLI_CONFIG_FOLDER + File.separator); 462 } 463 else { 464 return new File(System.getProperty(USER_HOME_PROPERTY) + File.separator + UNIX_GLI_CONFIG_FOLDER + File.separator); 465 } 466 } 467 468 397 469 }
Note:
See TracChangeset
for help on using the changeset viewer.