private void testFileIO(String fileName) {
try {
File file = new File(fileName);
FileOutputStream fos = new FileOutputStream(file);
byte[] byteArray = new byte[10];
byteArray[0] = 1;
byteArray[4]=1;
fos.write(byteArray);
fos.close();
FileInputStream fis;
fis= new FileInputStream(file);
while (fis.available() > 0){
System.out.print(fis.read());
}
fis.close();
file.createNewFile();
System.out.print("\n");
File file2 = new File("654321.bin");
//file2.createNewFile();
//file2 should be created before as arg of renameTo()
System.out.println(file.renameTo(file2));
//renameTo may create the old file and the new file,transmit data from old to new.
//old 0,new 0,success,old none,new created
//old 1,new 0,success,old none,new created
//目标文件不存在时,总能成功,源文件被重命名
//old 0,new 1,fail,old created,new null
//old 1,new 1,fail,old created,new null
//目标文件存在时,总是失败,源文件在目录中存在并为原文件名(不论之前是否创建)
System.out.println(file.getName());
fis = new FileInputStream(file);
while (fis.available() > 0){
System.out.print(fis.read());
}
fis.close();
//file对象中可读写数据而无须物理上的存在。
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
分享到:
相关推荐
Test Script..........................................................................................................................23 Conclusion.........................................................
named Test.pch and a precompiled types file named StdAfx.obj. Resource.h This is the standard header file, which defines new resource IDs. Microsoft Visual C++ reads and updates this file. //////...
1 Introduction to Oracle Service Bus 2 Tasks Working with Projects, Folders, Resources, and Configurations ................................................... 2-1 Resource Naming Restrictions ...........
Use Kill to remove the original file and then use Name to give the temporary file the old file name."<END><br>8 , cpyfile.zip This will copy a specified file to a directory. It also shows its ...
After you find a framework file you could pull it via adb pull /path/to/file or use a file manager application. After you have the file locally, pay attention to how Apktool installs it. The number ...
System.out.println("文件名是否更改成功:" + f1.renameTo(f2)); // 改名以后的的状态 System.out.println(f1.getName() + "是否存在" + f1.exists()); System.out.println(f2.getName() + "是否存在" + f2...
average faster than native DLL distribution and 100% reliable (original test of zlib 1.1.4 version).How to compress and decompress a file:procedure TForm1.Button1Click(Sender: TObject);var InputStream...
When Netatalk is being switched to UTF-8 which is supported in version 2 then it is NOT sufficient to rename the file names. There needs to be done more. See ...
Systems Used to Test the Examples Acknowledgments Chapter 1. UNIX System Overview Section 1.1. Introduction Section 1.2. UNIX Architecture Section 1.3. Logging In ...
Fixed the SFX code so that it works properly if you use Copy /B to concatenate a zip file to the stub. Due to a Delphi strange behavior sometimes path names for directory only entries would become ...
ICS - Internet Component Suite - V8 - Delphi 7 to RAD Studio 10 Seattle ======================================================================= ...Rename the old ICS directory and unzip to...
A batch file, convert_forms_to delphi_4_format.bat, is supplied in the demo directory which automates the conversion process. The C++ Builder demo forms are distributed in binary format. 7) If ...
Using Grunt, Mocha, and PhantomJS to test and deploy projects 281 Working with Grunt 283 Summary 284 Appendix A: Organizing Your Work 285 Loading and using modules 286 Understanding the module object ...
A new Export/Import function allows you to export specific preference sections to a file, and to import them on another PC. The following preferences options have been added: Files/Format/Encoding: ...
Connected to an idle instance. SQL> startup^C SQL> startup ORACLE instance started. 2、在双机环境下 要想启动或关闭ORACLE系统必须首先切换到root用户,如下 su - root a、启动ORACLE系统 hareg -y ...
几个等效命令test,/usr/bin/test,[],和/usr/bin/[ 7-3. 算数测试使用(( )) 7-4. test死的链接文件 7-5. 数字和字符串比较 7-6. 测试字符串是否为null 7-7. zmore 8-1. 最大公约数 8-2. 使用算术操作符 8-3. 使用&&...
几个等效命令test,/usr/bin/test,[],和/usr/bin/[ 7-3. 算数测试使用(( )) 7-4. test 死的链接文件 7-5. 数字和字符串比较 7-6. 测试字符串是否为null 7-7. zmore 8-1. 最大公约数 8-2. 使用算术操作符 8-3. 使用&&...
Copy the file to the new location and rename it right away. example4: ycopy.exe -s=C:\Users\Yun Liu\Desk*\test\*Temp\*source*.txt;-b=C:\Users\Yun Liu\Desktop\test\backup\2010source.txt;-i=0;/o Only ...
git clone https://github.com/JackwithWilshere/Kaggle-Dogs_vs_Cats_PyTorch第2步: from the website https://www.kaggle.com/c/dogs-vs-cats/data download the file train and test1 to the file "./data" ...
cw Write archive comment to file d Delete files from archive e Extract files without archived paths f Freshen files in archive i[par]=<str> Find string in archives k Lock archive l[t[a],b] List...