How to print out a backslash in LaTeX
Sound like you want a backslash in text mode; since \backslash does not work, try \textbackslash. EDIT: \symbol{92} should also work.
Sound like you want a backslash in text mode; since \backslash does not work, try \textbackslash. EDIT: \symbol{92} should also work.
Thanks to KirkMcDonald on the #go-nuts irc channel, I solved this by assigning the output file to cmd.Stdout, which means that stdout writes directly to the file. It looks like this: package main import ( “os” “os/exec” ) func main() { cmd := exec.Command(“echo”, “‘WHAT THE HECK IS UP'”) // open the out file for … Read more
Reading a file into memory all at once as an array of lines is just a call to the readlines function: julia> words = readlines(“/usr/share/dict/words”) 235886-element Array{String,1}: “A” “a” “aa” ⋮ “zythum” “Zyzomys” “Zyzzogeton” By default this discards the newlines but if you want to keep them, you can pass the keyword argument keep=true: julia> … Read more
Using OpenOptions::append is the clearest way to append to a file: use std::fs::OpenOptions; use std::io::prelude::*; fn main() { let mut file = OpenOptions::new() .write(true) .append(true) .open(“my-file”) .unwrap(); if let Err(e) = writeln!(file, “A new line!”) { eprintln!(“Couldn’t write to file: {}”, e); } } As of Rust 1.8.0 (commit) and RFC 1252, append(true) implies write(true). … Read more
For manipulating files, the os package is your friend: f, err := os.Open(“myfile”) if err != nil { panic(err) } defer f.Close() For more control over how the file is open, see os.OpenFile() instead (doc). For reading files, there are many ways. The os.File type returned by os.Open (the f in the above example) implements … Read more
Select the entire buffer with C-xh, then use M-xwrite-region.
There is a createWriteStream method right below it. fs.createWriteStream(path, [options]) Returns a new WriteStream object (See Writable Stream). options is an object with the following defaults: { ‘flags’: ‘a’ , ‘encoding’: null , ‘mode’: 0666 }
All the compress packages implement the same interface. You would use something like this to compress: var b bytes.Buffer w := gzip.NewWriter(&b) w.Write([]byte(“hello, world\n”)) w.Close() And this to unpack: r, err := gzip.NewReader(&b) io.Copy(os.Stdout, r) r.Close()
Try function file_exists(name) local f=io.open(name,”r”) if f~=nil then io.close(f) return true else return false end end but note that this code only tests whether the file can be opened for reading.
As @Steven points out, a better way would be: public void writeToFile(def directory, def fileName, def extension, def infoList) { new File(“$directory/$fileName$extension”).withWriter { out -> infoList.each { out.println it } } } As this handles the line separator for you, and handles closing the writer as well (and doesn’t open and close the file each … Read more