Doing more with files with Java and PeopleCode
2011-12-15 22:34
417 查看
Doing more with files with Java and PeopleCode
Here are some examples of using java objects in PeopleCode to do more with files than you can in PeopleCode. We can get the last modified time, the size, and we can rename it.Local string &fileName; &fileName = "/path/to/file/myFile.txt"; /* Get a reference to a file object */ Local JavaObject &f = CreateJavaObject("java.io.File", &fileName); /* get a reference to the simple date format */ Local JavaObject &sdf = CreateJavaObject("java.text.SimpleDateFormat", "MM/dd/yyyy HH:mm:ss"); /* Get the last modified time as a string */ &mod = &sdf.format(&f.lastModified()); /* Get the size in bytes */ Local number &SIZE = &f.length(); /* Lets try to rename the file */ local string &newFileName; &newFileName = "/newPath/to/File/myfile.txt.backup"; Local JavaObject &fBU = CreateJavaObject("java.io.File", &newFileName); Local boolean &b2; &b2 = &f.renameTo(&fBU); If &b2 = True Then /* RENAME SUCCESSFUL */ ELSE /* SOMETHING HAPPENED */ END-IF;
相关文章推荐
- SqlException with message "Caught java.io.CharConversionException." and ERRORCODE=-4220
- Working with hashCode and equals methods in java
- java code to read xls and xlsx files
- AES encryption of files (and strings) in java with randomization of IV (initialization vector)
- All javaAPI with 例子 in 英文 and a lot more!!!
- SqlException with message "Caught java.io.CharConversionException." and ERRORCODE=-4220
- Working with hashCode and equals methods in java
- 利用webservice和.net技术上传和下载文件--Sending files in chunks with MTOM Web Services and .NET 2.0 from:http://www.codeproject.com/soap/MTO
- Java code for authenticating into SMTP server with Auth and TLS turned on..
- Reusing Code with ASP Include Files and Subroutines
- Testing Java with Jython and PyUnit
- Java Reflection Tutorial for Classes, Methods, Fields, Constructors, Annotations and much more
- Java基础之访问文件与目录——移动或复制文件和目录(MoveAndCopyFiles)
- Android studiio 编译时候 报错C:\Program Files\Java\jdk1.7.0_71\bin\java.exe'' finished with non-zero exit
- ZIP and UNZIP with Passwords in Java
- Manage, Administrate and Monitor GlassFish v3 from Java code usingAMX & JMX
- Dealing with Difficult People: Lessons from Iran and Cuba
- Exception in thread "main" java.lang.Error: Always run main and tests with assertions enabled
- Tutorial: Loading and parsing external XML and JSON files with Unity
- Adding Jar Files With Dependencies And Modules