Java Doc for IOUtil.java in  » Portal » stringbeans-3.5 » com » nabhinc » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » stringbeans 3.5 » com.nabhinc.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.nabhinc.util.IOUtil

IOUtil
public class IOUtil (Code)
Provides utility methods for reading / writing from files / URLs
author:
   Padmanabh Dabke
author:
   (c) 2001 Nabh Information Systems, Inc. All Rights Reserved.




Method Summary
public static  voidconvertToUTF(Properties props, String fromCharset)
     Utility method to convert values in specified properties object to UTF-8.
Parameters:
  props - The Properties object which values to be converted.
Parameters:
  fromCharset - Characters encoding.
public static  voidcopyDirectory(File srcDir, File destDir)
    
public static  voidcopyFile(File srcFile, File destFile, boolean overwrite)
    
public static  voidcopyFile(File srcFile, File destFile)
    
public static  voidcreateFile(String filePath, String newContent, String charset)
     Create a new file with content and file path specified.
public static  booleandeleteDirectory(File dir)
    
public static  voiddeleteFile(String filename)
     Delete a file.
public static  SerializabledeserializeObject(byte[] ser)
     Reads a Java object from the byte array.
public static  SerializabledestringifyObject(String str)
     Deserializes an object from a string.
public static  byte[]getBytes(InputStream inputStream)
    
public static  byte[]getFileContentAsBytes(File file)
    
public static  StringgetFileContentAsString(File file, String charset)
     Reads contents of a file as a string and encodes based on character encoding specified.
public static  StringgetFileContentAsString(File file)
     Reads contents of a file as a UTF-8 encoded string.
public static  StringgetInputStreamContentAsString(InputStream is, String charset)
    
public static  StringgetInputStreamContentAsString(InputStream is)
     Reads contents of an input stream as a UTF-8 encoded string.
public static  StringgetURLContentAsString(String urlStr)
     Reads contents of a URL as a string.
public static  voidloadSystemPropertiesFromFile(String file)
     Reads properties from a file and merges them with the System properties.
public static  voidloadSystemPropertiesFromURL(String urlStr)
     Reads properties from a URL and merges them with the System properties.
public static  voidmergeWithSystemProperties(java.util.Properties props)
     Merges given properties with system properties.
public static  voidsaveAndBackupFile(File file, String newContent)
     Create a backup (old content) of a file (with extension .bak) and update the content of the specified file based on UTF-8 charset encoding.
public static  voidsaveAndBackupFile(File file, String newContent, String charset)
     Create a backup (old content) of a file (with extension .bak) and update the content of the specified file.
public static  voidsaveInputStreamContentToFile(InputStream is, String filePath)
    
public static  byte[]serializeObject(Serializable obj)
    
public static  StringstringifyObject(Serializable obj)
    



Method Detail
convertToUTF
public static void convertToUTF(Properties props, String fromCharset) throws IOException(Code)
Utility method to convert values in specified properties object to UTF-8.
Parameters:
  props - The Properties object which values to be converted.
Parameters:
  fromCharset - Characters encoding. The charset's name must be one of name supported java.nio.charset.Charset charset
throws:
  IOException -



copyDirectory
public static void copyDirectory(File srcDir, File destDir) throws IOException(Code)



copyFile
public static void copyFile(File srcFile, File destFile, boolean overwrite) throws IOException(Code)



copyFile
public static void copyFile(File srcFile, File destFile) throws IOException(Code)



createFile
public static void createFile(String filePath, String newContent, String charset) throws IOException(Code)
Create a new file with content and file path specified. It will attempt to overwrite the existing one if the file is writeable.
Parameters:
  filePath - The file path
Parameters:
  newContent - The file content
Parameters:
  charset - Characters encoding. The charset's name must be one of name supported java.nio.charset.Charset charset
throws:
  IOException - Thrown if the file path is not specified or trying to overwrite read only file.



deleteDirectory
public static boolean deleteDirectory(File dir)(Code)



deleteFile
public static void deleteFile(String filename) throws IOException(Code)
Delete a file.
Parameters:
  filename - File to be deleted.
throws:
  IOException - If the file is not exist, or a directory, or not able to be deleted.



deserializeObject
public static Serializable deserializeObject(byte[] ser) throws java.io.IOException, ClassNotFoundException, java.rmi.RemoteException(Code)
Reads a Java object from the byte array.
Parameters:
  ser - Byte array holding serialized object Deserialized Java object
exception:
  java.io.IOException - Thrown in deserializing the object
exception:
  ClassNotFoundException - A class referenced bythe deserialized object is not found
exception:
  java.rmi.RemoteException -



destringifyObject
public static Serializable destringifyObject(String str) throws IOException, ClassNotFoundException(Code)
Deserializes an object from a string. The string is assumed to be Base64 encoding of the byte array containing the serialized object
Parameters:
  str - Base64 encoded string of serilized object bytes Original object
throws:
  IOException -
throws:
  ClassNotFoundException -



getBytes
public static byte[] getBytes(InputStream inputStream) throws IOException(Code)



getFileContentAsBytes
public static byte[] getFileContentAsBytes(File file) throws java.io.IOException(Code)



getFileContentAsString
public static String getFileContentAsString(File file, String charset) throws java.io.IOException(Code)
Reads contents of a file as a string and encodes based on character encoding specified. Default character encoding is UTF-8. String holding the file contents
Parameters:
  file - File to be read
Parameters:
  charset - Characters encoding. The charset's name must be one of name supported java.nio.charset.Charset charset
exception:
  java.io.IOException -



getFileContentAsString
public static String getFileContentAsString(File file) throws java.io.IOException(Code)
Reads contents of a file as a UTF-8 encoded string.
Parameters:
  file - File to be read Contents of the file with UTF-8 encoded.
throws:
  java.io.IOException -



getInputStreamContentAsString
public static String getInputStreamContentAsString(InputStream is, String charset) throws java.io.IOException(Code)



getInputStreamContentAsString
public static String getInputStreamContentAsString(InputStream is) throws java.io.IOException(Code)
Reads contents of an input stream as a UTF-8 encoded string.
Parameters:
  is - Input stream to be read Contents of the file with UTF-8 encoded.
throws:
  java.io.IOException -



getURLContentAsString
public static String getURLContentAsString(String urlStr) throws java.io.IOException(Code)
Reads contents of a URL as a string. String holding the file contents
Parameters:
  file - File to be read
exception:
  java.io.IOException -



loadSystemPropertiesFromFile
public static void loadSystemPropertiesFromFile(String file) throws java.io.IOException(Code)
Reads properties from a file and merges them with the System properties.
Parameters:
  file - Property file path.
exception:
  java.io.IOException - The property file could notbe found.



loadSystemPropertiesFromURL
public static void loadSystemPropertiesFromURL(String urlStr) throws java.io.IOException, MalformedURLException(Code)
Reads properties from a URL and merges them with the System properties.
Parameters:
  file - Property file path.
exception:
  java.io.IOException - The property file could not be found.



mergeWithSystemProperties
public static void mergeWithSystemProperties(java.util.Properties props)(Code)
Merges given properties with system properties.



saveAndBackupFile
public static void saveAndBackupFile(File file, String newContent) throws IOException(Code)
Create a backup (old content) of a file (with extension .bak) and update the content of the specified file based on UTF-8 charset encoding.
Parameters:
  file - File which content to be updated.
Parameters:
  newContent - New content
exception:
  java.io.IOException -



saveAndBackupFile
public static void saveAndBackupFile(File file, String newContent, String charset) throws IOException(Code)
Create a backup (old content) of a file (with extension .bak) and update the content of the specified file. Default character encoding is UTF-8, if charset is not specified. If the file does not exist, it will attempt to create one.
Parameters:
  file - File which content to be updated.
Parameters:
  newContent - New content
Parameters:
  charset - Characters encoding. The charset's name must be one of name supported java.nio.charset.Charset charset
exception:
  java.io.IOException -



saveInputStreamContentToFile
public static void saveInputStreamContentToFile(InputStream is, String filePath) throws java.io.IOException(Code)



serializeObject
public static byte[] serializeObject(Serializable obj) throws IOException(Code)
Serializes the given object into a byte array
Parameters:
  obj - Byte array containing serialized object.
throws:
  IOException -



stringifyObject
public static String stringifyObject(Serializable obj) throws IOException(Code)
Creates a Base 64 encoded string representation of a serialized object
Parameters:
  obj - Object to be serialized String representing the serialized object.
throws:
  IOException -



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.