Process « Operation « Java I/O Q&A





1. Starting a process with inherited stdin/stdout/stderr in Java 6    stackoverflow.com

If I start a process via Java's ProcessBuilder class, I have full access to that process's standard in, standard out, and standard error streams as Java InputStreams and OutputStreams. ...

2. What is the best(least impacting?) method to read a file that is being written by another process?    stackoverflow.com

I'm looking for the least impacting method to read a few different log files. By "least impacting" I mean the read wont affect log rotation, wont cause undue I/O activity, ...

3. How do I trim a file extension from a String in Java?    stackoverflow.com

What's the most efficient way to trim the suffix in Java, like this:

title part1.txt
title part2.html
=>
title part1
title part2

4. Process Builder waitFor() issue and Open file limitations    stackoverflow.com

I have inherited some code:

Process p = new ProcessBuilder("/bin/chmod", "777", path).start();
p.waitFor();
Basically, there is for some ancient and highly voodoo based reason for storing key/value pairs on disk as files. I don't ...

5. How to prevent file from being overridden when reading and processing it with Java?    stackoverflow.com

I'd need to read and process somewhat large file with Java and I'd like to know, if there is some sensible way to protect the file that it wouldn't be overwritten ...

6. Cannot Delete File Within A Child Process Started From A C# App    stackoverflow.com

How do I invoke a child process from C# with UseShellExecute set to false and allow file deletion? The child process is a java program creates a 0 byte file, transfers it ...

7. File Processing    stackoverflow.com

I'm writing a game in which user can create his own level and remove them also. The only trouble is that I want files to be saved with names as level1, level2, ...

8. Java: Using Command line arguments to process the names of files    stackoverflow.com

I'm a writing a program that will determine the number of lines, characters, and average word length for a text file. For the program, the specifications say that the file or ...

9. Java file management on process forking    stackoverflow.com

My guesses were wrong, and had nothing to do with the answer. This question is no longer valid. See my answer. Sorry about this poor question.

Tl;dr Version

Why can't a Java ...





10. Dump file analysis of Java process?    stackoverflow.com

If I take dump, using Windbg, of Java process running on Windows Can I analyze (easly?) the Java heap, objects, and threads? Just like I could do with SOS for .Net process? Otherwise - ...

11. Java: can't get stdout data from Process unless its manually flushed    stackoverflow.com

I'm writing a terminal wrapper for a command-line program in Java, and I spawn the subprocess using ProcessBuilder. To send keystrokes to the subprocess, I just write e.getKeyChar() from the ...

12. If I implement UTF-16 file handler, can it accurately process all other encodings    stackoverflow.com

I am writing a small scale HTML crawler in java. I want to have a single file handler that can open all the HTML file one by one and process them. ...

13. Does creation of new File(filename) object associate a process file descriptor with the object?    stackoverflow.com

Does the following statement: new File(filename); associate a process file descriptor with the File object? Tried to search the same but without any success. Ideally, it should not statically associate the file descriptor with ...

14. FFMPEG in Java issue    stackoverflow.com

I have the following code in a java Web Service:

public boolean makeFile(String fileName, String audio)
    {
        if (makeUserFolder())
    ...

15. Is there a Java library for processing ONIX files?    stackoverflow.com

I've had a search around, but I couldn't find any java libraries to process ONIX files. I guess there is always the option of processing the XML directly, but I thought I'd ...

16. Java file address during processing of contents    stackoverflow.com

I am passing in directory into java and it will search for few keywords in each file. Then i want to output the keyword with the file it came from. Is ...





17. how to continue processing even though encountered file not found in a loop?    stackoverflow.com

System.out.println("Please enter the required word  :");
   Scanner scan = new Scanner(System.in); 
   String word = scan.nextLine();
   String [] array = word.split(" ");
   ...

18. delete file in java    stackoverflow.com

i want to delete file on windows OS using java, how ever some time file may be in use by external process, how can i delete forcefully or by knowing which ...

19. 2 java processes - one reading and one writing to the same file    stackoverflow.com

I have two java processes which I want completely decoupled from each other. I figure that the best way to do this is for one to write out its data to file ...

20. How to use javas Process.waitFor()?    stackoverflow.com

I am trying to run command line commands from Java and a quick sanity check made me realize that the reason I am having trouble is that I can't get the ...

21. Java: how to handle two process trying to modify the same file    stackoverflow.com

Possible Duplicate:
How can I lock a file using java (if possible)
I have two process that invoke two Java programs that modifying the same text ...

22. Efficient Pattern for processing fixed width files    stackoverflow.com

I have a case where in I need to read a flat file with close to 100000 logical records. Each logical record is comprised of nx128 character parts. ie, Type A: ...

23. How To know status of a file whether it is in processing or not in java which is platform independent?    stackoverflow.com

In File Monitoring process if one file came and it is processed immediately it does not check if file is open and writing something..Then how to prevent moving of file without closing ...

24. How would my Java program process a JS file to extract function names?    stackoverflow.com

Possible Duplicate:
How to get method name from JavaScript file
I want to fetch Java Script function name in my Java file.I mean i want some ...

25. Java batch processing    stackoverflow.com

I will read 2000 files and do some works on them with java. So I think I should use batch processing. But How could I do ? My system is Windows ...

26. change tream input in process    coderanch.com

Hello, I have a function define as follow: ProxyStreamHandler(InputStream from, OutputStream to) { LineNumberReader in=null; BufferedWriter out=null; BufferedInputStream from=null; BufferedOutputStream to=null; String firstLine = null; byte [] byteInSecondLine = new byte[20]; this.from = new BufferedInputStream(from); this.to = new BufferedOutputStream(to); in = new LineNumberReader(new InputStreamReader(from)); out = new BufferedWriter(new OutputStreamWriter(to)); firstLine = in.readLine(); //after I read first line, can I do this? ...

27. Why cant I read Process input staream??    coderanch.com

Hi, I am executing a ptogram from the command prompt that outputs CPU load every second to the screen. c:\>typeperf 1 "\Processor(0)\% Processor Time" "Sample Time","\Processor(0)\% Processor Time" "03/30/2001 11:14:43.843","0" "03/30/2001 11:14:44.843","0" "03/30/2001 11:14:45.843","0" "03/30/2001 11:14:46.843","0" (typeperf comes with resoure kit) I am tried to execut the same program from Java and read its input stream and then print it to ...

28. JRE causing defunct tail processes?    coderanch.com

Below we have some code that reacts to each new line of text entered into a file ( the "tail" process below sends the file in as the System.in in AIX ) public void run() { InputStreamReader in = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(in); try { while (getContinueRunning()) { System.out.println("SERVER_CONSOLE_WAITING"); fireOnConsoleEvent(new ConsoleEvent(this, reader.readLine())); } ...... Script to launch Java ...

29. process.waitFor() causes program to hang!    coderanch.com

I've successfully created a Process and run it using Runtime's exec(String path), and the kinds of processes I've successfully run have included Winzip, a WS_FTP Pro script, and a regular .bat file. I've also successfully called waitFor() on these processes, but in this particular case I'm calling a program that takes a file I give it as a parameter and merges ...

30. How do I check if a file is open by any process?    coderanch.com

Hello, How do I check if a certain file on the client desktop is open by any process? Here is the scenario: I generate a vb script from an applet to print a pdf file. I do not know how long the file is being printed. So, I want to check of the file is open any process on the machine, ...

31. Exit Values for a Process    coderanch.com

Is there any way to know what exit value represents what? I know that 0 represents normal termination, but for abnormal stuff ...?? I'm trying to copy a file using Runtime.exec.. and for some reason its failing but I can't seem to know why...coz its not throwing an exception... I have an if else condition i.e. if exitvalue=0 print(success) else print(failure)... ...

32. Strategies for processing files that exceed memory    coderanch.com

Greetings Java Gurus! This is my first post and is intended to help me get an appreciation for what I must learn to solve a problem that I have. I must create a program that can process 2.5 billion integers (6 gigs) stored in a file. Conceptually, the file is a 2D matrix of 50,000 rows and 50,000 columns. My program ...

33. File Processing    coderanch.com

I have to process huge files (upto 80MB) and the structure of the file is as below. Basically a huge file has 'N' segments of data with the header and footer and may have to trim some elements at the end on each line. Then I have to take each segment (between start to end) and call my parser to create ...

34. How to process big file?    coderanch.com

FileInputStream will read one byte at a time or a chunk at a time from now until the cows come home, so it can handle any size file. If you're storing those bytes in memory you can surely run out, though, so your next question is right on the money. To split a big file in pieces, you could use a ...

35. Knowing when another process has finished writing to file    coderanch.com

Hi, We have the following situation: - Some (non-java) process is uploading files to some directory. files are huge (several Giga), and size is *not* known in advance. - We need java to monitor this directory, and tell when a file has finished uploading (so the entire file is ready on disk). Is there a way to do it ? Some ...

36. Need help communicating with a java.lang.Process (a web browser)    coderanch.com

Can anyone please advise me on how I can send URLs to a java.lang.Process [created in my app by using Runtime.getRuntime().exec(pgr)] which references a web browser instance? User action in my application should be able to send another post request to the existing instance of Internet Explorer. I've tried simply writing the URL to the OutputStream of the Process but I ...

37. Starting a process and using STDIN/STDOU/STDERR    coderanch.com

Hi all, I'm starting a linux interactive console application that uses the ncurses library, from my SWING application. The program starts ok, but even if i don't do anything with the stdin stream object, it keeps sending line feed characters to the process. I guess this is some kind of weird stream initialisation from the spawned process (maybe due to ncurses). ...

38. java IO, File Processing    coderanch.com

properties file mon_range = 09:00, 20:00 tue_range = 09:00, 20:00 wed_range = 09:00, 21:00 thu_range = 09:00, 18:00 I wrote a java program which reads properties file, performs logic and confirms on user input from console. On typing 'Y' the user should be allowed to proceed? Shell script is written to invoke the java program. 1. I have only one main ...

39. Batch processing    coderanch.com

I need to a load a file which consists of transactional data into a database every night. This file may contain 100s of 1000s of records. Is there an existing framework which has been written to do just this? If not, is there an "accepted" approach to batch process large files in java? Ive never written a batch job before. My ...

40. reading the standard out from another process    coderanch.com

Hi all, I have written a piece of C code and I want to be able to read the output from that process into my java application. All output from the C application goes to standard out. I can start the application with the Runtime.exec command, and use the Process.getInputStream() method to direct data from the running process to either java's ...

41. Can not read a process?    coderanch.com

Does anyone has any idea why input.readLine() would not print? Here is the code: public static void main(String args[]) throws Exception { try { Runtime rt = Runtime.getRuntime(); String[] cmd = { "javac.exe", "c:/Temp/Test.java"}; Process p = rt.exec(cmd); int exitVal = p.waitFor(); String[] cmd2 = { "java.exe", "-cp c:/Temp Test"}; Runtime rt2 = Runtime.getRuntime(); p = rt2.exec(cmd2); BufferedReader input = new ...

42. Processing a large comma-separated file    coderanch.com

Hello Friends, I need to read a very large comma-separated file (.txt or .csv - depending on requirement) and want to be able to skip a few records if they are already been processed. Like if for some reasons the file is processed halfway, I need to be able to set the counter to the location from where to begin processing ...

43. What is the best way to process a file from the clients local machine?    coderanch.com

Thanks for the input Gary. I just picked up Java Servlet Programming by Jason Hunter. I'm looking at his MultiPart class. Hopefully this will do the job. I do have a question though, do I have to save the file on the server side when it's uploaded or can I just process the content? I don't want the user to be ...

44. processing downloaded file offline    coderanch.com

45. How to process any random file?    coderanch.com

Hi all, I want to know which is the optimistic and widely used way of processing any file. Processing in the sense (1) To read the file (2) To delete some unwanted content (3) To append some content (4) To place the content at some specified location based on index as well as substring And many more. As far as I ...

46. Processing a huge input file    coderanch.com

First, unrelated to your main question: } catch (IOException e) { } Never do this. Ever. If an error occurs and is caught by the catch block, it will simply vanish, with no helpful information for the programmer. Hiding errors like this makes debugging much harder. If nothing else, just use a printStackTrace(): } catch (IOException e) { e.printStackTrace(); } Anyway... ...

47. issue with files reading and processing    coderanch.com

I have a two files,it has accid,txtype,amount. one person accid may exist in another file, task is to read contents from files and storing that values(accid,txtype,amount),then number of threads will access this file depending on the txtype like withdraw or deposit the processing should be done.If it is withdraw it has to check with other files data and balance.How can we ...

48. input and ouput problem with BufferedReader/Writer to external process    coderanch.com

Here is the issue. java program starts and launches an external program. I get the inputstream and outputstream of that process to play with. I can pipe all the inputstream information to a textarea just fine however... its when i want to give input to the outputstream that the problem occurs. I believe I'm just thinking of this the wrong way ...

49. Can't Delete File with Process    coderanch.com

I'm trying to delete image files from a virtual scrapbook. The user can upload file names with spaces, like "my pi.jpg" But when I try to delete them using a JAVA Process it keeps choking on the spaces. // remove old file String command = "rm "; try { //System.out.println("Executing>: "+command+sv.getPath()+newFileName); // Process com = Runtime.getRuntime().exec(pwd+command+fileIn+fileOut); out.println("command = " + command ...

50. Huge file processing    coderanch.com

Hi, I have a requirement where i have a property file(Name, Value pair) having 300,000 records and size is suppose 3 GB. I need to persist in the database. What approach can be taken to effectively persist in the database. I mean: 1. How to read the file? 2. What collections can be used? 3. How to effectively handle the transaction. ...

51. Pipe between Java and C processes?    coderanch.com

Hi everybody! I never had the chance to use pipes in Java so I'm a newbie in this field. I know from C that pipes can be used to communicate between 2 separate processes. When reading about this in Java I see two different definitions: 1. that a pipe can be used ONLY to communicate between threads in the same JVM. ...

52. Generating .dmp file thro' Java Process    coderanch.com

I am generating .dmp file of Oracle database using java ProcessBuilder. I pass expdp copmmand and supporting arguments to ProcessBuilder and start the process. Since database has too many tables, it takes quite a long time to complete file generation. File gets generated, no problem with that. Another job I have to do is, I have to keep watching when the ...

53. Problem with processing data files of size larger than 350 MB    coderanch.com

Hi All, Please find below the details of my query. Problem: I need to process a huge(350 MB size) data file in Java.The data file is is basically a concatenation of multiple XMLs together. What I need to do is.. (a) check if there are some unwanted characters in bewteen the XML tags (b) If Yes, remove the tags After the ...

54. Need an OO approach for bulk file rename process    coderanch.com

Hello all, I need to rename around 4,000 files on a windows PC. The files are digital photos called DSC_0001, DSC_0002 and so on and they are located in a directory with around 50 subdirectories. The rename information (old filename, new filename) will be contained in a text file that I will create from a MS Works database file (which contatins ...

55. File Import/Buffer processing issues?    java-forums.org

I'm trying to enhance a program that reads in a flat file that conatains multiple record types and only writes/prints out the first record of each type of record in the file. I created beans for each record type because I needed to shift the order of the fields in each record before printing them out. I am able to write ...

56. read file opened by other process    forums.oracle.com

57. The process cannot access the file because it is being used by another proc    forums.oracle.com

Well, you are going to have to track down what application(s) have the lock on the file and remedy that before you are going to have any luck or hope in fixing the problem. In sequential access files, you can only gain write access when another application does not have it locked.

58. File processing and e-business    forums.oracle.com

i'm being told that file processing methods are value for e-businesses "File processing" is a very broad term, and in general, it's no more or less important to e-biz than in other areas. Any application might want to store things in a file or read things from a file, for any number of reasons. Saying "file processing is impotant for ebusiness" ...

59. file processing... first time.    forums.oracle.com

haha, you replied fast. . i noticed that i didn't type a question in, and was going to edit, but it didnt work. Question: I basically want to scan for a name match by user input to the actual text database if it the same, i want to pull the line out and display it. when i type in the name, ...

60. Multiple processes reading/writing in the same file    forums.oracle.com

Hi people! Wrote a little java-program which reads after errors in a file, AND at the same time, another program is writing to the same file. The writing-part writes to the file whenever it got a string, the string contains information about events that occurs in some system and the information-string ends with a new-line ("\n"). The "reading-program" copies the file, ...

61. Process files ...    forums.oracle.com

Hi everyone, I want to write a program which will take two files and process them (i.e., check them for same string patterns). Till now what i have done is: I used BufferedReader and FileReader to read the contents of the files BUT my questions are 1. By using readers it takes line by line, let say if I want to ...

62. Need help for data file processing with java programming!!    forums.oracle.com

A Data file consists of a list of positive random integers. The numbers are separated by space. Design the pseudo codes to perform the following tasks: (a) Print all the numbers with 6 numbers in a line. (b) Calculate the total value of the odd numbers in the file.(for example: totalValue=3+7+11+19+and so on) (c) Print the largest and smallest numbers in ...

63. How to get the process blocking a file    forums.oracle.com

I think you can not find out the process using a file. but i can give you an idea by which you can explore all process on your system By which youcan sort out which process is using file by looking at the process. 1. Create a RunTime 2. create a process for command 3. retrive ...

64. Check if a process is trying to delete file    forums.oracle.com

Is it possible to check if a process outside of my program is trying to delete a file I have open for read only? I would assume this would be through some sort of event listener? For example: My java app has c:\test.txt open for read only Another process (say explorer.exe) tries to delete that same file (right now I get ...

65. Open a file for read, allow other processes to delete it?    forums.oracle.com

Normally yes I agree this is a little backward. And I do not want to lock the file, I want to allow other processes to delete the file that is open. Reason being.. say there is a background process that is appending some logs to file "MyFile.txt". My app is reading this file and watching for appends then it does something ...

66. Is it possible to process 500MB or more file in java?    forums.oracle.com

In my project, i need to process 500MB zip file. I am able to process upto 58MB file. If the file size exceeds, i got "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space" Is it possible to process 500MB or more file in java?If it is possible, how to process. Note: I need to split the 500MB zip file into 1MB ...

67. Process IO Problem    forums.oracle.com

I tried what you suggested and this is what happens... It starts the external application and prints out the one line which the application starts with (which is what I expected) then it constantly waits... how do I stop this waiting so that I can now write to the external application? I just need my application to supply one line of ...

68. Java File Processing    forums.oracle.com

Same idea just ignore it until you hit START_OF_DATA and ignore it again after you hit END_OF_DATA. Just for the record this is a really bad way to structure the data in your application. If you're doing it to prove how it could be done fine, if you're doing it because the data is structured in the file this way, change ...

69. How to open a file, process it with different runnables and then save it    forums.oracle.com

Right now I have one main class from where I call 2 image analysis (that they live in different classes). For the moment, the output is different. Actually the output image come from the process which is called second (if I want to run both together - reasonable result as the output image is overwriten by the second process).

70. Complex file processing    forums.oracle.com

All, project : Pull data from text files provided by big financial companies for account data. I am receiving text files in various formats, usually a variety of balance files and a variety of name and address files. Currently we do the following: Construct a Custom class to handle a particular company's file. The class reads the file and insert into ...

71. Create a Process with specific file descriptors    forums.oracle.com

I'm not at all sure this is even possible, but I'm trying to work around a really ugly problem. Java's subprocess management is really cozy in that it handles a lot of low-level stuff like closing file descriptors in the forked process. However, I would like the forked process (over which I have little control) to have the read end of ...

72. Processing bank files    forums.oracle.com

Hi everyone. I have a text file, filled with information provided by the bank where my company has an account. The information contained in it has to be imported into the company's system. The file contains a series of fields: numeric and alphanumeric. The length of a field is not static, I mean a numeric / alphanumeric field can be of ...

74. File processing task    forums.oracle.com

Hello, everybody! Task for resolve: I have *.txt file with constans which looks like: #define FIRST_CONSTANT 101 #define SECOND_CONSTANT 10101 #define THIRD_CONSTANT 7877 etc... So, I need to parse it and have the java.util.HashMap where keys - names of constants, and values - values of constants which in file. Ok, I started to think: how may I make my work easy? ...

75. Reading from a file which is used by another process    forums.oracle.com

Thnx for the rply. Now to do join() you have to specifically know what event you are waiting to finish. In this case wheather the file is successfully copied or not.Here how do you know that the file has been successfully copied or used by another thread or something like that. This is my basic question. How to know if there ...