write 1 « Operation « Java I/O Q&A





1. How do I use Java to read from a file that is actively being written?    stackoverflow.com

I have an application that writes information to file. This information is used post-execution to determine pass/failure/correctness of the application. I'd like to be able to read the file as it ...

2. Can I write to the end of a 5GB file in Java?    stackoverflow.com

Can I write to the end of a 5GB file in Java? This question came up in my office and no one is sure what the answer is.

3. write data to exel file using jexcelapi in java    stackoverflow.com

i'm begginer in java i have created exel file and write to that file by using jxl API. but the file is taking 14kB but in VC++ it will create with 2KB ...

4. How to compute accurately the time it takes a Java program to write or read a file?    stackoverflow.com

How to compute accurately the time it takes a Java program to write or read a number of bytes from/to a file ? It is really important that the time is being ...

5. How to write a UTF-8 file with Java?    stackoverflow.com

I have some current code and the problem is its creating a 1252 codepage file, i want to force it to create a UTF-8 file Can anyone help me with this code, ...

6. Problem writing to file    stackoverflow.com

I'm having a problem writing to a file:

FileInputStream fin;              
try
{
    fin = new FileInputStream ...

7. Java: Why isn't my file writing working?    stackoverflow.com

I'm trying to write a file from my Java program, but nothing happens. I'm not getting any exceptions or errors, it's just silently failing.

        ...

8. How do I correct this silent failure to write files using Java IO?    stackoverflow.com

I am encountering a strange issue with the commons-io/java-io. Essentially my file creation is failing silently without an exception.

FileUtils.writeLines(file, collectionOfStrings);
I've looked through the commons code to try and figure why this ...

9. Read from one large file and write to many (tens, hundreds, or thousands) files in Java?    stackoverflow.com

I have a large-ish file (4-5 GB compressed) of small messages that I wish to parse into approximately 6,000 files by message type. Messages are small; anywhere from 5 to 50 ...





10. How to write data to a file through java?    stackoverflow.com

I want to make a GUI application that contains three functions as follows:

  • Add a record
  • Edit a record
  • Delete a record
A record contains two fields - Name and Profession There are two restrictions for ...

11. Java File Write Question    stackoverflow.com

In Java, i am creating a text File for a batch file to upload in the other system. When i am writing into that file at the end of line i ...

12. Java FileLock for Reading and Writing    stackoverflow.com

I have a process that will be called rather frequently from cron to read a file that has certain move related commands in it. My process needs to read and ...

13. How do I tell what language is a plain-text file written in?    stackoverflow.com

Suppose we have a text file with the content: "Je suis un beau homme ..." another with: "I am a brave man" the third with a text in German: "Guten morgen. Wie geht's ?" How do we ...

14. Java long task - Did it stop writing to file?    stackoverflow.com

I am writing a lot of data to a file, and while keeping my eye on the file it eventually stopped growing in size. Essentially my task is getting information from a ...

15. Java. Writing a matrix in a file using column information. ( matrix transposition )    stackoverflow.com

I have a file in which a matrix is stored. This file has a RandomAccessFile type. This matrix is stored by columns. I mean that in an i-th row of this ...

16. Write to a file in java    stackoverflow.com

How can I modify this run method to not only print the srting in the output window, but also write to a file for example outfile.txt in project directory. Also each ...





17. How to write java program to increase file limit using ulimit    stackoverflow.com

I am using Fedora linux where ulimit -n 10000 increases file limit upto 10000. I want to achieve the same using java program How to write java program to increase file limit ...

18. Java: how to create and write to a file    stackoverflow.com

What's the simplest way to create and write to a file in Java? I know this is a very basic question, but the web is full of different answers for different versions ...

19. Java: file write on finalize method    stackoverflow.com

In my understanding a singleton object will destroy only when the application is about to terminate. So in C++ I write a Singleton class to log my application and in that ...

20. getResourceStream for writing files    stackoverflow.com

For javame. Since getResourceAsStream() is for reading files, is there a getResourceAsStream() equivalent for output stream / writing files? Note: the file is inside the project's folders and will soon be packaged ...

21. writing to a file problem    stackoverflow.com

I am using this code to write to a file in java. it has always worked and I am 100% sure its right. But still the file does not get written. I ...

22. Writing to new file    stackoverflow.com

I am using FileOutputStream for writing some data to a file. Every time I execute my program, it appends the data to existing file instead of creating new one. I want ...

23. Java Binary IO Writing and reading    stackoverflow.com

I have this kind of structure that I want to both read and write to a file, and I want to do it the fastest way possible.

class Map
{
  String name;
 ...

24. How can I write consecutive named files in Java?    stackoverflow.com

I have a method for saving a File, but I don't know how to save files with consecutive names such as file001.txt, file002.txt, file003.txt, filennn.text How can I achieve this?

25. Problem writing 0xFF to file    stackoverflow.com

I'm trying to write a 0xFF to file in java using PrintStream. Other values are written to the file correctly when I open it with a Hex editor but the value ...

26. Java: File i/o tuning    stackoverflow.com

I attempted to create a sort-of file generator which spits out hardcoded messages to a file with slight alterations to some of the strings based on user input. Since I'm utilizaing ...

27. Need Help In Writing To A File    stackoverflow.com

i have the following class that writes to a file but is not working as i want. I call the write method in a while loop so that it writes a ...

28. Reading HDF5 file that was written in java by octave    stackoverflow.com

I'm writing a framework to write HDF5 files that are compatible with Octave. That is, I want that my framework will be able to read HDF5 files that were written by Octave ...

29. java: openCSV not writing to file in recursive loop?    stackoverflow.com

in my main class

  public static void main(String[] args) {
            CSVWriter writer = new CSVWriter(new FileWriter("D:\\myfilefile.csv"), '\t');
   ...

30. Creating .obj files in Java    stackoverflow.com

is there a Java library in existence for creating .obj files. There are many for loading .obj files for use with APIs like JOGL but I can't find anything to do ...

31. help for writing to files in java    stackoverflow.com

Hi I have created a class named 'Human' that each object of this class has a name and a type which can be student or instructor. I have created another class main ...

32. JAVA : read and write a file together    stackoverflow.com

I am trying to read a java file and modify it simultaneously. This is what I need to do : My file is of the format : aaa bbb aaa ccc ddd ddd I need to read through ...

33. how to write the newline character as a string to a file java    stackoverflow.com

how can i write the newline character as a string to a file java. For example i want to write the string to the file "hello\nworld" as it is to a file. Thank you, Rana. ...

34. Java IO - read a big file while other application writing to it    stackoverflow.com

I want to use java to read a weblogic log file while weblogic is writing log into it (buffered),but I only want read content that is present when I start to ...

35. Is there a Java library for writing out ply files?    stackoverflow.com

I'm looking for a Java library to write out ply files. If there isn't one, I'd like to look into writing one.

36. Need suggestion on my approach : to read a file which is being written continuously?    stackoverflow.com

I have one csv file, which is being written continuously by script. It writes timestamp and some other data per row. I have to read the latest data first. Currently I am ...

37. Can objects be written to and read from files?    stackoverflow.com

I think the answer is yes, but I just wanted to make sure. anyone's help would be greatly appreciated

38. java write data to file without erasing the old content    stackoverflow.com

how can i write data to file without erasing the old content

39. Fastest way to write to file?    stackoverflow.com

I made a method that takes a File and a String. It replaces the file with a new file with that string as its contents. This is what I made: ...

40. how can I create executable file for the program written on Java?    stackoverflow.com

everyone, how can I create executable file for the program written on Java in Eclipse Helios? I mean to create small icon to be able start program only by double-clicking on ...

41. File Read and Write    stackoverflow.com

I Have a code for writing into a file each time there is an entry into the textfield. but after the process, when an entry is made again the file is ...

42. Writing a file in Java    stackoverflow.com

Good day! I have a project (game) that needs to be presented tomorrow morning. But I discovered a bug when writing in the high scores. I am trying to create a text ...

43. How to write a file indexing software in java?    stackoverflow.com

I want to write a software to search my hard disk for pdf files and index them in a library by analysing the content . Please help me how to achieve it ...

44. writing javascript in ftl file    stackoverflow.com

I have an ftl file which is sending a notification e-mail. I need to change the subject line of these mails. So, far I have managed to change the subject and ...

45. Writing to file with Java    stackoverflow.com

I am trying to write a simple method to save my document to a file (overwriting any previous contents of the file.) Unfortunately, my implementation does not seem to work. I ...

46. Recreating a file and writing new contents    stackoverflow.com

I am trying to delete a line from a text file in java, I have read around and it seems that there are a couple of solutions: delete the file and ...

47. writing data in to files with java    stackoverflow.com

I am writing a server in java that allows clients to play a game similar to 20 questions. The game itself is basically a binary tree with nodes that are questions ...

48. How to avoid writing BOM character to a file?    stackoverflow.com

I have some Java code that writes to a text file, specifying UTF-8 as encoding. Now, some of the files written contain a <U+FEFF> character at the very start, which creates a ...

49. write and read in file in java    stackoverflow.com

hi im trying to read from a file, take the length of the each line , write the length into another file and then print the second file to see the writing ...

50. File writing in Robocode (Java)    stackoverflow.com

basically, I am trying to generate a log file in Robocode, but I am having issues as you cannot use try/catch in Robocode (as far as I am aware). I have ...

51. Writing to a File in Java    stackoverflow.com

I'm really new to Java, and I can't write to a file for some reason, my code looks like this:

FileWriter fstream;
    try {
      ...

52. First Java program (writing permutations to a file)    stackoverflow.com

I'm trying to write combinations with repetitions to a text file, the problems is I'm trying to hack together some code without knowing the inner workings of java. I'm not really ...

53. reading and writing character by character from and to the file in java    stackoverflow.com

Possible Duplicate:
Java File IO Compendium
I want to read a file char by char in Java, and write characters into file, also in Java. Can you ...

54. writing file to java issue    stackoverflow.com

I have a java program that writes a file using the BufferedReader, however, at the end of the file it always ends up as it was not finished. Something like as ...

55. How do I determine the size of a dynamically allocated structure in Java before writing it to a file?    stackoverflow.com

Say, for example, I have a complex dynamically allocated structure (such as a binary tree) that needs to be written to a file made up of different sections. I would like ...

56. Is there an smart way to write a fixed length flat file?    stackoverflow.com

Is there any framework/library to help writing fixed length flat files in java? I want to write a collection of beans/entities into a flat file without worrying with convertions, padding, alignment, fillers, ...

57. Write HTML file using Java    stackoverflow.com

I want my Java application to write HTML code in a file. Right now, I am hard coding HTML tags using java.io.BufferedWriter class. For Example:

BufferedWriter bw = new BufferedWriter(new FileWriter(file));
bw.write("<html><head><title>New Page</title></head><body><p>This ...

58. How to add newlines while writing to file using java?    stackoverflow.com

    String filepath=jTextField1.getText();
    FileReader fr;
    try {            
    ...

59. Writing from System.out.println to a file    stackoverflow.com

I've replaced many strings and outputted the result and now am trying to write those lines into a text file. Here's what I did. I created a new file:

File newfile ...

60. java - very fast writing to a file    stackoverflow.com


I get a fast stream of data (objects) and I would like to write it to a file.
This is a stand alone process so it doesn't do anything but read the ...

61. write xth row in file in Java    stackoverflow.com

in Java, suppose I have a text file with n rows, is it possible to only write and replace row x? or do I rewrite all the rows in order ...

62. I have written an object to an java file i/o got junk data in that file    stackoverflow.com

I have created an file in java which has object written in that file file has an text extension but got an junk character.Any tips,program or tutorial available ...

63. Read and a write a file in a reverse order - Java    stackoverflow.com

I have a very big file (might be even 1G) that I want to create a new file from in a reversed order (in Java). For example:

Original file:

This is the first line
This ...

64. Adding special characters while writing into a java file but not visible everywhere    stackoverflow.com

I am writing into a java file through

               FileWriter fstream = new FileWriter("someFile.java");
    ...

65. DataNucleus: Write to two storages (RDBMS & file system) at once?    stackoverflow.com

I'm currently implementing a map application. Part of the data is stored in a database, part in the file system. As the amount of model objects has grown and I could ...

66. Is it possible to write to the same file from different methods?    stackoverflow.com

I have the following method:

public static void writeContestantsToFile(ArrayList<Contestant> contestants) throws IOException {
    FileOutputStream fos = new FileOutputStream("minos.dat");
    ObjectOutputStream oos = new ObjectOutputStream(fos);

    ...

67. How to write file data correctly?    stackoverflow.com

My application is unable to transfer data properly over a socket connection and write it to a file properly. Files over about 65,535 bytes get corrupted and are no longer recognized ...

68. Java - How to read and write a file simultaneously?    stackoverflow.com

Is there any way in java to read a file's content, which is being updated by another handler before closing it?

69. Writing string to a file in java    stackoverflow.com

I have a file which contains sql statements. Now in this file, I want to add a word "collate" after every 'char()' and 'varchar()' in the file. How do you do that?

70. writing '\t' '\n' etc. characters in a file like a string_?    stackoverflow.com

hi there i am trying to write a code that generates automatically code and writes in a file.so the problem is when i try to write '\t' '\n' etc. characters i ...

71. write a string into file    stackoverflow.com

I have the above code. What i wanna do is to write in a txt file a string.

     import java.io.*;
    import java.util.*;

   ...

72. Buffered Methods in Java for writing Objects in Files?    stackoverflow.com

I wanted to know if its possible or there is some library for having buffered I/O methods for writing/reading objects in java (ObjectOutputStream, ObjectInputStream). Thanks in advance for your help. Besnik.

73. Writing a long (primitive type) to a file in Java    stackoverflow.com

Hi all, I have an array of long that I would like to write into a .txt file that I can later open in gedit (one number per line). I get those ...

74. reading a file while it's being written    stackoverflow.com

I've read some posts on stackoverflow about this topic but I'm still confused. When reading a file that is currently being written in Java, how do you keep track of how ...

75. Write to a new file with a string variable name in Java    stackoverflow.com

I want to create a new file and write to it. The following code works just fine:

    StringBuffer string = new StringBuffer("sdfsdfsdf\nsdfsadfsdfsdf\n");
    BufferedWriter write = new ...

76. Need help writing to input/output file in java    stackoverflow.com

New to java and need some help. I am working with 2 files. One defines a class and all of it's methods and another constructs an instance of this class. My ...

77. Writing html file back to browser : Java    stackoverflow.com

I've read a request for an HTML document from my browser, parsed the file from the request, found the specified file, and now all that's left is to send back the ...

78. How to write multiple objects to file?    stackoverflow.com

I want to write multiple objects to a file, but the problem is that I dont have all the objects to write at once. I have to write one object and ...

79. Writing long string in Java to file    stackoverflow.com

I'm trying to dump a large integer array (10 000 elements) into a text file but am encountering some problems. I've tried two different approaches and neither seems to be working. ...

80. reading from the file and writing to the file in java    stackoverflow.com

Sorry for my bad language. I am beginner of Java. This is my approach: I am trying to read two files and then get the union of them. I should use an array with ...

81. Writing software to read proprietary files such as .tns    stackoverflow.com

How would I go on doing this? .tns is used by TI-Nspire (math-software) created by Texas Instruments. If any libraries exist it would be awesome. Otherwise, how would I go on doing this ...

82. Can i read and write files on the kindle filesystem from a kindle active content app?    stackoverflow.com

Can Kindle Development Kit Applications read and write to files placed on a kindle by usb? my program would pretty much do the following 1.a user/supervisor places an xml or json file ...

83. Why do I get "nul" when writing to a file?    stackoverflow.com

I am using Java BufferedWriter to write to a file line by line. The problem is that when I finish writing the file it shows "nul" all over the file. I do ...

84. How to write content to a file    stackoverflow.com

try {
    File file = new File("sample.txt");
    FileWriter fw = new FileWriter(file,true);
    fw.append('d');
    fw.write(100);
    fw.close();
} catch(IOException ...

85. problem to write two constructor in a file    bytes.com

hi, I create one file with only one constructor which contain one Frame with GUI.When I create object of that file for getting some values in another file then that GUI ...

86. How to Write the Read-only file in java?    bytes.com

You can not write the read-only file, since it is read-only and you can write if you have appropriate file permissions. Regards Dheeraj Joshi

87. file writing problems    bytes.com

You close your fstream. Then you return a closed fstream which you don't assign to a variable in your code. Your write function attempts to open an fstream which you don't ...

88. how to write result in file.....    coderanch.com

Hello everybody, I am parsing a text file using stream tokenizer. on command line I invoke the class ( code is given below) as : javac Tokenexample myfile.txt "*" and it gives me correct output .. i.e delimits whole file based on Word, Character and Numbers. My question is : I want to Write the output to a different file say ...

89. writing in file at the end of file    coderanch.com

hello there , I am writing in file using following code , it writes in file is ok but for every time it writes in file and deletes previous information in file , how can I write in file that whenever printwriter writes in file it starts writing at the end of file , so previous information in file remain as ...

90. need help writing to a file    coderanch.com

Im trying to write to an already existing file, but my problem is that once I write to the file everything is overwritten. So prior to writing Legacy.txt contained john, joe, james and in the end it only contains text, and i want it so that it would contain john,joe,james,text can anyone help Thank you for your time if(OptionsPane.itemStr[i-1] == OptionsPane.itemStr[0]) ...

91. Which is the best way to write and read from a file    coderanch.com

I want to write some names to a file which i want to retrieve later in my program for searching purpose I tried using RandomaccessFile but there we have writechars() for writing as a string and readLine for reading but the problem is that even if i enter two strings and while reading i want to read them one by one ...

93. how do I create a new File in order to write info    coderanch.com

here u go: import java.io.*; import java.util.*; public class update { public static void main(String args[]) throws IOException { File f=new File("c:/update.txt"); String today=(new Date()).toString(); FileWriter fw=new FileWriter(f); fw.write(today); fw.close(); } } p.s. the Date() constructor is i suppose deprecated but i dont know the new version. [This message has been edited by guy ranch (edited May 19, 2001).]

94. Reading from file A, writing to file B    coderanch.com

Hello. I would like to read text file "A", manipulate the text, and write the result to text file "B". This is what I've come up with: import java.io.*; public class Transcriber { public static final String IN_FILE = "C:\\ajmin.txt"; public static final String OUT_FILE = "C:\\ajmout.txt"; private BufferedReader br; private FileReader fr; private BufferedWriter bw; private FileWriter fw; public static ...

95. seeking and writing to a file    coderanch.com

I am familiar with the file io in java, but it seems like I have some holes in my understanding that I would greatly appreciate being filled if possible. Now the way I see it you have to use the randomaccessFile class to seek anywhere in a file, but you only hacve very simple write methods associated with that class, white ...

97. Writing objects to files    coderanch.com

98. Write file to a client system    coderanch.com

I am attempting to create a file consisting of data I retrieve from the database on a browser. I am able to create the file on the server side. Can anyone let me know how can I do it on the client side? Essentially, I should be able to ask the user to choose a folder to save the file and ...

99. please help about reading and writing    coderanch.com

100. Need A hand With my home work (write to a file)    coderanch.com

Hi all can some one plz help me with this for some reason this compiles fine but it wont write to the file I tell it to im stumped....this files are in the same directory as the .java file..... if you have the awnser plz post some code to help me get my mind wraped around this concept...thkz import java.io.*; import ...