Questions tagged [writer]

an abstract class, interface or naming convention which is used to state that the given object is used to write data to a file, stream, device or other destination

A Writer clause is often used as a part of a name of an object in object-oriented programming. Good examples are BufferedWriter from Java 6 or StreamWriter from C#.

Abstract writers are often defined as interfaces or abstract classes to provide means of making the process of writing separable from what is being written. In Java or .NET there are Writer implementations for files, network connections and, more general, streams.

456 questions
5
votes
3 answers

ObjectOutputStream writing extra characters

I know that writers should be used instead of outputstreams when writing text, but still I don't understand why there are extra characters in the file outputStream.txt after running this program: public static void main(String[] args) throws…
Luis Sep
  • 2,384
  • 5
  • 27
  • 33
4
votes
4 answers

Writing key:value pairs to a tab-delimited file with variable #s of values

Beginner question: I have a dictionary where the values are lists of (a variable # of) strings. Ultimately, I would like to write each dictionary entry to a single tab-delimited line with the key as column 1 and the individual items from the value…
pandaSeq
  • 213
  • 2
  • 6
  • 12
4
votes
1 answer

How to work with RFID reader/writer in Java

I bought a USB RFID reader/writer to develop an attendance application. Along with the device they given VB example to read/write RFID tags. But I want to do this in Java. Is there any way to start programming which read/write the RFID tags. And one…
Dyapa Srikanth
  • 1,231
  • 2
  • 22
  • 60
4
votes
1 answer

Excel::Writer::XLSX adds an unexpected @ in formula (part 2)

This question follows a first question : Excel::Writer::XLSX adds an unexpected @ in formula I am writing a formula to an xlsx file using Excel::Writer::XLSX While I am using _xlfn, I do not have the expected result when I try to write a complex…
Jean-Marc
  • 133
  • 1
  • 9
4
votes
1 answer

Haskell: make a Writer as efficient as normal code when log is not needed

I'd like to write one code that could be run in two "modes": either in logging mode, i.e. it should log some informations (in my case I want to log the number of calls done on some particular functions at a given time) or in efficient mode, i.e. it…
tobiasBora
  • 1,542
  • 14
  • 23
4
votes
1 answer

Haskell MonadWriter type signature

Noob question on MonadWriter: monadWrite :: Writer String Int monadWrite = writer (3003, "log 1\n") Why is it that String comes first in the typesig and Int second, while 3003 is clearly an Int while "log 1\n" is a String. Trivial I know, but I…
Madderote
  • 1,107
  • 10
  • 19
4
votes
1 answer

How efficient is the writer monad for lists?

The implementation of the Haskell writer monad on lists (Writer [w] a) will use ++ to add items. So if I write this code in a list writer monad: do tell [a, b, c] tell [d] The lists will be appended with [a, b, c] ++ [d]. After working in…
Calebmer
  • 2,972
  • 6
  • 29
  • 36
4
votes
4 answers

How to write a text to file with GWT on Client-side?

Is there any way to implement write/read file with gwt on client-side? I tried with java.io.File, java.io.Writer ... I couldn't succeed. thx in advance! Update: Please see my own answer for a solution
Jama A.
  • 15,680
  • 10
  • 55
  • 88
4
votes
1 answer

python 3 how to write utf-8 using csv writer

I have this problem when trying to write a csv file : from csv import writer str1 = "idzie wąż wąską dróżką" str2 = "мир и любовь" csv_file = open("myFile.csv", "a", newline="", encoding="utf-8") writer_Obj = writer(csv_file, delimiter=';') …
eden clarck
  • 182
  • 2
  • 10
4
votes
3 answers

Golang buffer with concurrent readers

I want to build a buffer in Go that supports multiple concurrent readers and one writer. Whatever is written to the buffer should be read by all readers. New readers are allowed to drop in at any time, which means already written data must be able…
Tympanix
  • 113
  • 1
  • 2
  • 9
4
votes
2 answers

Read/copy up to a certain number of bytes from `io.Reader` to `io.Writer` in Golang, or return error if OVER a certain bytes limit?

I have an io.Reader in Golang and I want to double-check that the size of its data is below a predetermined maximum before or while running io.Copy() to save it to disk using io.Writer. Since the file data in io.Reader could theoretically be quite…
Ben Guild
  • 4,881
  • 7
  • 34
  • 60
4
votes
1 answer

java write the list string into csv file

I have some array strings like the following (note that there is space after each player which shows different lines...), ["user1","track1","player1", "user1","track2","player2", "user1","track3","player3", ...] I would like to divide this array…
mOna
  • 2,341
  • 9
  • 36
  • 60
4
votes
1 answer

Should I use a try-with-resources statement for each line of log?

I want to log (append text) into a file every time something happens. I find this might be the correct way to do this with Java 7's try-with-resources statement: public void log(String textLine) { try(PrintWriter output = new PrintWriter(new…
Kewei Shang
  • 949
  • 3
  • 11
  • 27
4
votes
1 answer

How to write text between two lines in a text file. Java

This is for Java I'm trying to write a program that writes to a text file using PrintWriter. I've been able to add text to the end of the file but I need to be able to write text in between two words. Ex: text before: dog mouse text after: dog cat…
4
votes
4 answers

Python CSV Writer leave a empty line at the end of the file

the following code leave a empty white line at the end of the txt file. how can i not have the writerows not terminate the last line? with open(fname, 'wb') as myFile: # Start the CSV Writer wr = csv.writer(myFile,…
M. of CA
  • 1,496
  • 2
  • 22
  • 32
1 2
3
30 31