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
1 answer

How to set FileWriter object positon?

Suppose I have to count the number of instances of a word in a line. After reading a line if there are no instances of that word in that line I want to delete that line. How can I set FileWriter cusrsor position to FileReader and then append "\b"?
user2899644
  • 113
  • 1
  • 6
-1
votes
1 answer

Close the file writer in vb.net

Dim file_lines() As String = System.IO.File.ReadAllLines("c:/file.txt") lone_lines(1) = final_lone 'lone_lines(here is the line number) = final_lone System.IO.File.WriteAllLines(Add,…
-1
votes
1 answer

In Java, whenever I run my code, my txt file gets wiped

Whenever I run my code, the inv.txt file changes from having 25 lines of the character 1 to nothing, could someone tell me what I'm doing wrong? PS the main class includes inventory.addItem(); public class inventory { File inventory = new…
drdavehere
  • 21
  • 6
-1
votes
2 answers

Separate a .txt file by empty line and copy into another .txt file

I've been searching the web but to no avail. My problem is that I have one log text file that contains text like 2014-03-04 08:28:45 1WKkiT-0008Qr-M9 Message received from xx (1.2.3.41) T="q" 2014-03-04 08:28:45 1WKkiT-0008Qr-M9 Message was…
-1
votes
1 answer

Java Objectwriter, Save Classes

i want to save some of my classes when my java program is running. So i can load them if i start the program again. It works just fine with 2 out of 3 classes (the save() code is the same in all classes except for the saveURL). but this one seems to…
user2078872
  • 1,507
  • 3
  • 12
  • 16
-1
votes
5 answers

Why does nothing write to my file?

I have a program that I am working on and I have an issue with writing a string into my file. The file is created, but the string value that should be written into it ultimately does not get written. There are no syntax errors according to Eclipse,…
Code4Fun
  • 41
  • 1
  • 5
-1
votes
1 answer

File resetting after running

Okay, I'm coding something that will generate a crypt, and assign each letter a string of a random value of anywhere from 2 to 6 import java.io.*; import java.util.*; public class filewriters { public static void main(String[]…
-1
votes
3 answers

filewriting and reading in java always returns as null

Help! The code keeps returning as "nullnull"! I am trying to make it so that if I have multiple elements, it will display it into the console. This is more of a two part question... 1. I am saving multiple different element symbols to one variable,…
-1
votes
2 answers

File read, changed but how to write out?

Ok, forgive my beginner-ness and please tell me how I can output my text from "before.txt" into a fresh new file called "after". Obviously I have altered the text along the way to make it lower-case and eliminate non alphabetic characters. import…
-1
votes
1 answer

Keeping an organized record of scores

I'm creating a game that needs to keep track of the highscores as different people play it. I'd like it to be able to organize itself, so that the top player stays at the top, and the file isn't always overwritten when a new score is added. I need…
Hoberfinkle
  • 35
  • 1
  • 7
-1
votes
3 answers

After EOFException variable=null

If I end the client session a EOFException is thrown but I read that this would be normal so I just start a new thread with the same functionality but the value of Restaurant=null; although i wrote it in a .txt file public void run(){ try { …
Sebastian Walla
  • 1,104
  • 1
  • 9
  • 23
-1
votes
3 answers

How to print a Scanner's results on a screen

I have a scanner that can read a txt file that I am trying to print on the screen. I am trying to do this by printing the scanner (scan) results of what the user typed in on the on the screen using Graphics g. Any Ides on how to do this a different…
user2540802
  • 95
  • 1
  • 1
  • 4
-1
votes
1 answer

writing a file issue in java

i want results saved in a file and using recursive method which rewrite the object and nothing save. if i try to declare the printwriter globaly then it give me the error "Default constructor cannot handle exception type UnsupportedEncodingException…
Waqas
  • 315
  • 1
  • 6
  • 21
-1
votes
1 answer

Writing logs on file on external sdcard on android devices

I have an application where I write logs on a file located on the external memory card. This application runs on a lot of same devices, samsung galaxy S2, and when a user reports a problem we retrieve the logs through an mdm system in order to…
Apperside
  • 3,542
  • 2
  • 38
  • 65
-1
votes
1 answer

Where is my com.something.myapp stored at when I run my project in eclipse and load it to my phone?

When I run my android project in eclipse through my device the app shows up on my phone with the little android dude. It runs fine, does what it is supposed to do. I am writing to some '.txt' files in my app and I cant locate the .txt files in my…
Matt
  • 379
  • 3
  • 9