Questions tagged [writetofile]

for questions concerning the writeToFile method, part of the NSData class in OS X and iOS

This tag should be used for questions that relate to the use of one or more of the various writeToFile methods, which are provided by the NSData class in both the Mac OS X and iOS APIs.

The Apple developer documentation for the NSData class is available online here.

351 questions
2
votes
1 answer

Having trouble trying to add a line to a text file if that line doesn't exist already using Python fileinput.FileInput(...)

I'm trying to edit text files using the Python FileInput class. First I store the lines that i need to write in a Dictionary. Then I iterate through that dictionary, and if the dictionary[key] matches any line in that line, I replace the line with…
user695624
  • 123
  • 1
  • 8
2
votes
1 answer

writeToFile not working on NSDictionary with UIImagePickerControllerReferenceURL inside

I have an NSURL inside a NSDictionary, which looks like this: assets-library://asset/asset.JPG?id=1000000001&ext=JPG This NSURL is from UIImagePickerControllerReferenceURL. Without this object, the NSDictionary saves using this code fine: BOOL…
Andrew
  • 15,489
  • 25
  • 116
  • 200
2
votes
2 answers

write a string into file

I have the above code. What i wanna do is to write in a txt file a string. import java.io.*; import java.util.*; public void writeAsfalizomenos(asfalizomenos myObj) throws IOException { Scanner scanner = new Scanner(System.in); …
snake plissken
  • 2,489
  • 9
  • 37
  • 61
2
votes
4 answers

Writing list to file for reuse at a later date

I have a python file that requires a username and password for authentication. These username and passsword details are saved to the file in the format userlist = [[username, password], [username1, password1]] and so on. This works but when I…
Max Davies
  • 27
  • 4
2
votes
3 answers

NSDATA writeToFile crashes without a reason

I am downloading images from a url using NSDATA and saving them to local file system using NSData *dataForStorage = [NSData dataWithData:UIImagePNGRepresentation(img)]; BOOL saveResult=[ dataForStorage writeToFile:jpegFilePath…
2
votes
2 answers

How to write data to a text file in Flask?

Our goal is to write a variable called "inputed_email" into a text file named "test3.txt". Because this takes place on the server, we need to make sure that this Python script can access the directory and text file. @app.route('/', methods=['GET',…
Evan Yang
  • 115
  • 1
  • 8
2
votes
2 answers

iOS Write Data to file, FILE DOES NOT EXIST

I'm tryin to write the datas of an Image in the cacheDirectory, like this : let imageData = UIImageJPEGRepresentation(image, 1.0) else { fatalError("Impossible to read the image") } try! imageData.write(to: cachedImageURL, options:…
Alexis Darnat
  • 561
  • 6
  • 13
2
votes
0 answers

read write file to 5 decimal places in borland c++

I writing with borland C++ compiler. I want to read numbers with 5 decimal places from text file then save it into another text file. I wrote my program as below: main { double Bid[25], Be1[25],Bn1[25]; int i,no=10,j,p; char filename[30]; …
2
votes
1 answer

NSData writeToFile returns NO without any error

I know many topics already exist but none of them seems to enlighten my problem. I am supposed to get a PDF file back from a JSON request on a server. The downloading task process is called but when I try to store my NSData to a file, it does not…
2
votes
2 answers

Creating separate files

I am looking for a way to create separate files. For example: I have an application which has a form such as name, date etc. and when I press save, I want to save all the information in that form of the user into a file. Each time the form is filled…
Aneesa
  • 113
  • 3
  • 10
2
votes
1 answer

Why can't I use write(toFile: ) property on a string?

I'm following a tutorial that was written in some earlier version of Swift, that teaches me how to read/write a .txt file in Swift3. Xcode has been doing a good job so far of letting me know when I'm using old syntax, and changing it for me to the…
Theodore.K
  • 404
  • 2
  • 6
  • 20
2
votes
1 answer

Using Xcode 7/Swift 2 writeToPath to Resources file the call does not fail but no data is written

I am using Xcode 7.3.1 and Swift 2.0. I am using the following code sample: func writeToResourcesDataDir() { if let path = NSBundle.mainBundle().pathForResource("TestData", ofType: ".json") { let str = "Test String" do { …
D Stallmo
  • 31
  • 5
2
votes
1 answer

Write Image To File in Directory

I am getting an error when writing an image file to a directory in Xcode. The function data.writeToFile is returning an error. Here is what I am trying to do: Get The File Path: func getPath(fileName: String) -> String { let documentURL =…
hockeybro
  • 985
  • 1
  • 9
  • 33
2
votes
2 answers

How to insert labels on top of images saved to .WriteToFile in PNG's Swift

I'm trying to save a label on top of an image using .WriteToFile . Here's the code I'm using to save the image : let selectedImage: UIImage = image.image! let fileManager = NSFileManager.defaultManager() let paths =…
Niall Kehoe
  • 359
  • 1
  • 4
  • 17
2
votes
2 answers

Java/JSP: Preserve line breaks while writing to a local file from string variables

I need help to create read-write methods that write to a file and preserve the line breaks. The contents of the file are stored in a variable. I use the following code to read a local HTML file: public String scanLocalPage(String filePath) throws…
user1492667
  • 139
  • 3
  • 13
1 2
3
23 24