- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Writting to a read only file throws NO exception!
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2002 09:52 AM
тАО06-25-2002 09:52 AM
Writting to a read only file throws NO exception!
By the way this same code works on another HP-UX machine I tested it on. Are there any patches associated with such an issue?
The test program I use is,
import java.io.*;
public class TestFile
{
public static void main(String[] args)
{
System.out.println("Hello World!");
TestFile ff= new TestFile();
ff.writeFile();
System.out.println("done");
}
public void writeFile()
{
try
{
File f = new File("./testfile.txt");
FileOutputStream fos = new FileOutputStream( f );
fos.write("aaaaaa".getBytes());
f.setReadOnly();
fos.close();
FileOutputStream fos1 = new FileOutputStream( f );
fos1.write("dddddddd".getBytes());
fos1.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2002 12:45 PM
тАО06-25-2002 12:45 PM
Re: Writting to a read only file throws NO exception!
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2002 01:06 PM
тАО06-25-2002 01:06 PM
Re: Writting to a read only file throws NO exception!
If the application is run as superuser, it will overwrite/modify the file in question irrespective of who the owner is and the file permission.
If you want an exception thrown, modify your application to check the file permission before writing to the file. If it read only it should throw and exception else write to the file.
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2002 01:09 PM
тАО06-25-2002 01:09 PM
Re: Writting to a read only file throws NO exception!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2002 01:09 PM
тАО06-25-2002 01:09 PM
Re: Writting to a read only file throws NO exception!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2002 01:12 PM
тАО06-25-2002 01:12 PM
Re: Writting to a read only file throws NO exception!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2002 01:23 PM
тАО06-25-2002 01:23 PM