disk « Development « Java I/O Q&A





1. can we determine at runtime whether a file is deleted from hard disk or not using java    stackoverflow.com

I am creating my project in which I am indexing all files of my PC in a database. Now I want to know at run-time whether a file is deleted, moved or ...

2. Disk partition structure    stackoverflow.com

Is there any way in Java (1.6+) to retrieve the partition disk structure? (For example: NTFS, FAT32, HFS+, or EXT3.) External libraries are permitted. Thanks,
Gianni

3. Encryption of Objects stored to disk using C++ (for a Java Developer)    stackoverflow.com

This is two questions in one but hopefully trivial to a C++ developer.

  1. How can I seralize an object so that I can write it to disk and retrieve it later in ...

4. Java: fastest way to do random reads on huge disk file(s)    stackoverflow.com

I've got a moderately big set of data, about 800 MB or so, that is basically some big precomputed table that I need to speed some computation by several orders of ...

5. Ten latest files on disk    stackoverflow.com

I need effective algorithm to keep only ten latest files on disk in particular folder to support some kind of publishing process. Only 10 files should present in this folder at ...

6. How can the block size of a file store be portably obtained in Java 7?    stackoverflow.com

I believe the title says it all. I've looked at java.nio.file.attribute.Attributes and java.nio.file.FileStore, but couldn't find a way to discover the block-size of a disk-file.

7. java api for XML - dom processing with disk backup    stackoverflow.com

I have a large XML document (50G+) to process. Loading this to normal dom (saxon) require more than 160G. Not that much RAM or swap space. Is there any library ...

8. Can a java RAM disk be created to be used with the java.io.* API?    stackoverflow.com

I'm using a 3rd party library which basically creates an output directory with different kinds of files and subdirectories inside. I would like to be able to write unit tests to ...

9. Write to disk file incorrect    stackoverflow.com

I would like to write out the values of my array to a file.

public void Write(String fileName) throws IOException
{

    PrintWriter outFile;
    outFile = ...





10. How to handle disk full errors in java    stackoverflow.com

I am working on a java application. We read lot of data, manipulate it and then write to files in local m/c. If, in any case, the disk is full then ...

11. Allocate disk space for multiple file downloads in Java    stackoverflow.com

Is there any way of reliably "allocating" (reserving) hard disk space via "standard" Java (J2SE 5 or later)? Take for example the case of a multithreaded application, executing in a thread pool, ...

12. Easy way to get total number of files on disk?    coderanch.com

Hello, Here's a little something I wrote up real quick with your question in mind. I haven't tested it too extensively, but it looks like it works. I haven't tried it at all on a *NIX based system. Let me know how it works for you... import java.io.*; public class NumFiles { private File theRoot; private int fileCount; public static void ...

13. Writing BufferedImage to disk    coderanch.com

Hi All, Can someone tell me if it is possible to write a BufferedImage using ObjectOutputStream to disk? I realize that it is not serializable. Is it possible to cast it to another object, write it, then later read it back and cast it back to BufferedImage? If this is not possible, what other options do I have for storing images ...

14. hard disk i/o and java ....urgent    coderanch.com

friends, using java, i need to determine if the hard disk is being written to or read from (open/copy) at any time ie. if in an os like windows, if i create a new file and try to save it to the hard disk, my java program (running perpetually in the background) should pop up a dialog box informing me that ...

15. finding out disk space    coderanch.com

import java.io.*; class test{ public static void main(String args[]){ Runtime r = Runtime.getRuntime(); Process p = null; String s = "df -k ."; try{ p = r.exec(s); InputStream in = p.getInputStream(); BufferedReader res = new BufferedReader(new InputStreamReader(in)); String resString = null; while(( resString = res.readLine()) != null) System.out.print("Output is "+resString); } catch(Exception e){ System.out.println("Exception is"+e); } } }

16. LowLevel Disk managment in Java    coderanch.com

Hi, I have something similar in nature, but there are some weakness into it. You can digest it, if you liked. Regards, MCao import java.io.*; import java.util.*; public class GetDiscSpace { public static void main( String[] str ) { Runtime rt=Runtime.getRuntime(); String strDiskSpace=null; Process p=null; String strOS=System.getProperty("os.name"); try { if(strOS.equals("Windows 2000")) { p = rt.exec("cmd.exe /c dir d:\\"); } else { ...





17. Serialize many objects to disk..is it possible?    coderanch.com

Dear All, I am writing an app that reads about 1,000,000 records. Each record is transformed to an object and i am applying some transformations to those objects. The final step is to serialize these objects to disk. I have tried the following : public class Test { public static void main(String args[]) { Test t=new Test(); int capacity=2000000; GenericObject gen; ...

18. How to find the available disk space    coderanch.com

Not without JNI native coding down to the particular OS running on. Regardless though, your app shouldn't need to know this. If you're trying to determine if there's "enough" space before doing something, instead just assume there is enough, and fail as gracefully as you can if you get an I/O error.

19. Writing Integer Object to disk    coderanch.com

I want to write an Integer Object to the disk and then read it back. I can't figure out the command for reading it back. I know it needs to be cast as appropriate wrapper class. Someone please help. Thanks File fd = new File("d:\\Number.dat"); try { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fd)); out.writeObject(new Integer(17)); out.close(); ObjectInputStream in = new ObjectInputStream(new ...

20. Getting the free disk space    coderanch.com

Dear Proteu, I have an alternative. You may not like it, but it's better than nothing. I managed to solve the problem of disc space reporting by downloading the excellent and free Cygwin, and calling the "df" command with exec(). You don't need to have the entire Cygwin distribution installed on the machine executing the code when you use df: I ...

21. how to get current root object after pause to copy to disk    coderanch.com

hi everybody I am struck at a point where i am tring to copy the objects from a pipe to a module.The module has a pause method which stops the process of copying from the pipe for some fixed time,but i want to safeguard the records in progress and save them to disk.I am writing the following code to write the ...

22. How to figure out total disk size in Java?    coderanch.com

I think this is the best you can do, and try to find a similar program for different OSes. Even if you recursed the whole directory tree (hardly practical anyway), you would face problems such as being denied access to some files, and not accounting for the space wasted in each block at the end of files.

23. FileNotFoundException when writing to the hard disk ???    coderanch.com

Hi.I have files read from client machine. And then I want to write them to the server machine. At the stage that the server wants to write files to the hard disk. I get FileNotFoundException sometimes. It doesn't happen every time. And even if it happens, it only happens to the one or the second file that server writes. All other ...

24. View Hard Disk Drives in Java    coderanch.com

Good point Rob - so naturally I had to try it - here is what I ran: public static void main( String[] args ) { File[] roots = File.listRoots(); System.out.println("Found " + roots.length + " roots " ); for( int i = 0 ; i < roots.length ; i++ ){ System.out.println( roots[i].toString() + " exists= " + roots[i].exists() ); } System.out.println("Done" ...

25. Floppy Disk Lock    coderanch.com

No, there isn't such a method in Java. You can make a 3.5 inch floppy read-only by physically changing the switch on the floppy itself (to open/close the hole on the disk). There's no way to make a floppy read-only with only software (neither with Java nor with a native function call).

26. saving a file to disk    coderanch.com

27. how to store a file in the local hard disk    coderanch.com

Hi In the below code i am using outputFile as fixed Location.what i want is the user must select his own location to store the file code ------------ String outputFile="E:/one.xls"; //String outputFile="one.xls"; if(action.equals("CreateExcelFile")){ try{ connMgr = DBConnectionManager.getInstance(); con = connMgr.getConnection("sjo"); Debug.println("The connection is..."+con); stmt = con.createStatement(); String sql="select product,month,sales from testdata"; // Create a New XL Document HSSFWorkbook wb = new ...

28. Upload multiple file without saving to disk    coderanch.com

Hi All I'm looking at a way to upload 2 files and process them without saving to disk.Basically i have a rates file which contains exchange rates and another file that has expenses. have to get the exchange rates from the first, and do some calculation based on the expenses on the other. most examples i got over the net save ...

29. How to know Remaining Disk Space with JDK 1.5    coderanch.com

I'm reading about jakarta commons IO FileSystemUtils class. It has the method freeSpaceKb: public static long freeSpaceKb(String path) throws IOException Returns the free space on a drive or volume in kilobytes by invoking the command line. FileSystemUtils.freeSpaceKb("C:"); // Windows FileSystemUtils.freeSpaceKb("/volume"); // *nix The free space is calculated via the command line. It uses 'dir /-c' on Windows, 'df -kP' on AIX/HP-UX ...

31. Disk Wiper\Security using Java IO?    coderanch.com

I want to write a program to wipe out all files on a hard drive that has been deleted by Windows. I know I need a way to insure I write to every unused sector to wipe out all traces of unused files. Does anyone know how I can do this? (I know there is commercial software to do this. This ...

32. java.io.IOException: There is not enough space on the disk    coderanch.com

Note that read() returns "-1" when you're at end-of-file. This line received += is.read(buffer, 0, buffer.length); is a big mistake, as it uses the return value of read without checking first for the "-1". If anything goes wrong during the transmission, this line is going to bite you. If you look at your code, you can see that if when you ...

33. Byte[] to File without saving on disk    coderanch.com

Hi fellows!!, how are you?, i have been developing an applet to digitally sign PDF files, the applet gets those files from a php page, sign the files and last send each signed file to another php page for saving them in a data base. The problem is in the uploadSignedFile method, this method sends the signed file, receives one parameter, ...

34. can i use java to check the disk usage?    coderanch.com

Here's 3 source files that I pulled out of one of my projects which should get you started (hope I got them all, if not, let me know). import java.io.File; public class DirSize { private static final String SPACES = ". . . . . . . . . . . . . . . . . . . . . ...

35. Hard disk full but no IOException    coderanch.com

Hi all, i have here a java programe which writes data using 30 threads from a DB (Oracle) into files. The workflow is: Select unmarked data from DB Write data to file Mark data in DB (update) that the file was created Last weekend the hard disk was full and nobody recognized that. I thought there is no problem and i ...

36. cannot get the info from disk file    coderanch.com

In the future please put your code in code tags. Your code will be much more readable, and people will be more inclined to help you. Sorry, i do not know the answer. It has been a while since i have done stuff with reading files and the like. import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; public class importDataProcess { /** * ...

38. opening file from a random disk drive    forums.oracle.com

39. IOException when no disk space left    forums.oracle.com

In my program, I have to copy files of a quite substantial size from one media onto another. Since the free space is limited, I need to catch the case when it gets no longer available. The total size of files is unknown and cannot be computed beforehand (random element), so checking availability before copying each file would barely make sense. ...

40. Check that file exists on disk?    forums.oracle.com

41. Saving a file into another PC hard disk file system.    forums.oracle.com

Among other things, how you can do it will depend on: 1. Operating system both machines are running (e.g. Windows->Windows, Windows->UNIX etc.) 2. Is the destination location accessible/writable for user on source machine? Assuming Windows to Windows copy, one way could be to: 1. Map the destination drive/location on your source machine (can be done via windows explorer or net use ...

42. Require assistance on low level disk IO through Java.    forums.oracle.com

I am looking for some java Api manual or java code for low level disk IO. Precise problem is, I am having minix image and a pen drive. I want to boot my pc from minix. In order to make pen drive bootable I need to write the image to sector 0 for which I have no idea how to do. ...

43. saving a file on disk    forums.oracle.com

Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } } I recieve the next error: XSL-1110: (Fatal Error) Invalid StreamResult set in TransformerHandler. javax.xml.transform.TransformerException: XSL-1110: (Fatal Error) Invalid StreamResult set in TransformerHandler. at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:681) at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:268) at hospitalet.MngDataBase.SaveXMLRecordset(Hospitalet.java:485) at hospitalet.Hospitalet.main(Hospitalet.java:123) Caused by: java.io.FileNotFoundException: file:\C:\Develop\xmlRet.xml (El nombre de archivo, directorio o etiqueta ...

45. file finished written to disk verification    forums.oracle.com

46. How do I get the file size on disk?    forums.oracle.com

Actually, I really don't know what you say. But when you see the properties of a file in Windows, you can see there are two file size. One is called "SIze" and the other one is called "Size on disk". Therefore, I would like to know the size on disk but not just the size.

47. rename a file PROPERLY on disk    forums.oracle.com

Im trying to rename a file.. I know you're just going to tell me to use 'renameTo' but that doesnt actually change the files name on disk, it just changes to name of a 'File' object. How do I actually change the name of a physical file on disk that can be seen in a file browser or windows explorer? PERL ...

48. detect random disk drive and open random file    forums.oracle.com

49. How to create a file that points to a disk drive with no disk.    forums.oracle.com

Is there any way to by-pass the windows error "No Disk" "Exception processing message etc. etc when I say File disk = new File("A:/")? I don't get this error with Java 1.6 and Windows XP SP2. Mind you I had to add some other stuff to get your code to compile. I get this output: Drive C:/ exists Drive Y:/ exists ...