Questions tagged [filewriter]

Java built-in class that allows writing character files.

Public class FileWriter extends OutputStreamWriter.

Convenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream.

Whether or not a file is available or may be created depends upon the underlying platform. Some platforms, in particular, allow a file to be opened for writing by only one FileWriter (or other file-writing object) at a time. In such situations the constructors in this class will fail if the file involved is already open.

FileWriter is meant for writing streams of characters. For writing streams of raw bytes, consider using a FileOutputStream.

Since: JDK1.1

Source: Oracle

1133 questions
-1
votes
2 answers

FileWriter removing the Java.awt.Point

I am creating a program that will outprint the coordinates of a location. When it prints it out to the file, it looks like this: Car id distance #spots java.awt.Point[x=1,y=1] java.awt.Point[x=2,y=0] java.awt.Point[x=1,y=0] car0…
Chris
  • 246
  • 1
  • 5
  • 15
-1
votes
2 answers

cannot write in the file

good day guys, im creating a program that will write the data to a text file. the data is coming from an array list, it is a data that is solved from the array list e.g : public double getGincome(){ gincome=rpd*dwork; return…
NewInJava
  • 35
  • 1
  • 4
  • 12
-1
votes
4 answers

Why is nothing being written to a file?

I am creating and writing to a file using the following pattern: File afile = new File("C:/dev/ws/DataOrdering/data/" + thisDate + "_" + thisTime + "_visdata.csv"); FileWriter writer = new…
Ankur
  • 50,282
  • 110
  • 242
  • 312
-1
votes
1 answer

Why doesn't my code function like it should? (fileWriter, jTable)

Still having some issues with my code. No errors this time, its just not functioning properly! here's the code: http://pastebin.com/nm633L1v What's not working (I think): fileWriter jTable 3rd Party Libraries: OpenCSV filechooser.FileFilter : just…
ccreason
  • 189
  • 1
  • 7
-1
votes
1 answer

FileWriter() corrupt file warning

I have an app which converts jTable instances into an excel file. In my previous question, I had a problem in using FileOutputStream() and it turns out that the problem lies within the AD user's privilege in accessing folders/files. Since my…
Jaycroll
  • 9
  • 2
-2
votes
1 answer

BufferedWriter not writing data line by line

Currently trying to edit my old code from System.out.println() statements that display the results of a benchmark test to writing the results to 2 different .txt files. I am doing this so I can create a new program that uses JFileChooser to select…
-2
votes
1 answer

Is there an easy way to append a new column that will be having same value for all rows in csv?

I am processing a file as the following and closing it. Later, I do some more processing and get some ID that I want to append to all rows in the previous CSV generated. So all rows will have the same value. My initial code of creating and appending…
Atihska
  • 4,803
  • 10
  • 56
  • 98
-2
votes
2 answers

Why can't I write FileWriter outside of Try with resources?

So, I just wanted to create a program to copy the contents from one file(source1) to another file(source2) and convert it into lowercase... while doing so i have came up with the code as: try(FileWriter fr=new FileWriter("Source1.txt")){ …
-2
votes
1 answer

PrintWriter and FileWriter Instead of using File or Using File ( JAVA ) Program

For the simplicity of writing a lot and also boring you guys I just have a question and if you guys can give me another example as well using maybe something simpler. Here is the code PrinterWriter w = new PrinterWriter(new…
user3453661
  • 33
  • 1
  • 7
-2
votes
1 answer

How to solve fix 'list index out of range' while accessing large amount of data from file?

I am working on a classifier that will access 200000 data items from a dataset but it only accesses about 1400 data correctly and shows list index out of range. How can I access all of the items from the dataset? Here the structure of the dataset.…
Shah Alam
  • 23
  • 8
-2
votes
1 answer

Write 2D List to File Error: System.InvalidOperationException:

I have a List double [,] array. When i try to below code c# to write 2d double list array to file i got error. "System.InvalidOperationException: 'Collection was modified; enumeration operation may not execute.'" public void Write(List
K.Ense
  • 3
  • 2
-2
votes
1 answer

I want to read a text file and split it based on column value

public class FileSplitter2 { public static void main(String[] args) throws IOException { String filepath = "D:\\temp\\test.txt"; BufferedReader reader = new BufferedReader(new FileReader(filepath)); String strLine; …
-2
votes
2 answers

Create folder and print to text file from command

For example you have a command where the second argument is a directory plus file name: String fileName = "createF dir/text.txt"; String textToFile="apples, oranges"; How can I create "dir/text.txt", a folder called dir, a txtfile and write the…
Adam Hanek
  • 83
  • 1
  • 6
-2
votes
1 answer

How can i write to a file when distributable file is launched?

I have program that read from a file. Now I created another task, that aims to update/write this file into same files. My problem now is when I generate my project's distributable file, during running and try to update my file, it does not…
-2
votes
1 answer

My java code doesn't write a file on Linux

I have some code for entering my expenses. However, the program doesn't write a text file to a specified folder on Linux (Ubuntu 16.04). The program used to write normally the file in the folder where the code was. Now, I'm trying to write the file…
hbrtxito
  • 75
  • 7