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.

370 questions
5
votes
2 answers

Alternative/faster method to slow StreamWriter to print strings to a file in C#

Some help from experts. I'm trying to use the function below to print strings to a file. When I use Console.Write() or Console.WriteLine() the output file grows up 3MB or 4MB per seconds, but when I try to use StreamWriter or File.AppendAllText the…
Sarmeu
  • 95
  • 1
  • 3
  • 9
4
votes
2 answers

NSManagedObject hierarchy import and export

I'm on the run to make my NSMangedObjectClass profile im-/exportable. I try it this way Exporting works correctly if I write the Relationships in NSArrays because NSSet doesn't have writeToFile implemented. - (void) exportProfile:(Profile…
Seega
  • 3,001
  • 2
  • 34
  • 48
4
votes
2 answers

Android 6 - Writing to external storage fails ON FIRST RUN ONLY

I know a question almost like this was asked several times but that problem is different. I need to write data to the external storage. I know I need to ask for permissions at runtime on Android 6. All this works fine so far. Just one thing is…
Tobias Reich
  • 4,952
  • 3
  • 47
  • 90
4
votes
4 answers

Insert text in between file lines in python

I have a file that I am currently reading from using fo = open("file.txt", "r") Then by doing file = open("newfile.txt", "w") file.write(fo.read()) file.write("Hello at the end of the file") fo.close() file.close() I basically copy the file to a…
L0g1x
  • 66
  • 1
  • 6
4
votes
2 answers

How to Write data to file in angularJS

I have a variable with huge data some thing like this. $scope.employees = [ {"firstName":"John", "lastName":"Doe", "city": "Bangalore","State":karnataka,}, {"firstName":"Anna", "lastName":"Smith", "city":…
Amrut
  • 407
  • 1
  • 6
  • 5
4
votes
1 answer

Deleting file from device after using [NSData writeToFile:]

In my code I'm doing: [anNsDataObject writeToFile:@"thefile" atomically:YES]; How can I delete this file from my device?
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
3
votes
2 answers

What is the correct way to import & save Photos from iPhone Album?

I am Importing Photos from the iPhone Album to the documents folder of my application. This is my code. for (int j=0; j<[assetArray count]; j++) { ALAsset *assest = [assetArray objectAtIndex:j]; CGImageRef imageRef =…
Aravindhan
  • 15,608
  • 10
  • 56
  • 71
3
votes
3 answers

can't save plist. path is not writable

I'm saving a lot of informations in a plist. This one is by standart in my mainBundle. this is my method to load the path and the data from the plist. if the file in the "application support" folder doesn't exist, i'm copying it from the mainBundle…
Adrian
  • 524
  • 5
  • 21
3
votes
0 answers

bitMapToFile ERR: java.io.FileNotFoundException: /storage/emulated/0/image.jpg: open failed: EPERM (Operation not permitted) in android

I try code BitMapToFile but it has ERR!! class ImageProcess { companion object { fun bitmapToFile(imageBitmap: Bitmap , filename: String): File? { val sd = Environment.getExternalStorageDirectory() val dest =…
3
votes
2 answers

Ruby File.open not creating file

I'm trying to create and write to a new file using @logFile = File.open("C:\Users\---\Desktop\mylog.log", "w+") And nothing happens. My program uses @logFile.write ("Hello") @logFile.flush And this line seems to be running ok (no crashes or…
Itzik984
  • 15,968
  • 28
  • 69
  • 107
3
votes
3 answers

Cyrillic symbols shown strangеly when writing to a file

I have a class that has a string field input which contains UTF-8 characters. My class also has a method toString. I want to save instances of the class to a file using the method toString. The problem is that strange symbols are being written in…
bob_saginowski
  • 1,429
  • 2
  • 20
  • 35
3
votes
1 answer

R writing to stdout very slow. Any ways to improve?

I am writing a simple command-line Rscript that reads some binary data and outputs it to as a stream of numeric characters. The data is of specific format and R has a very quick library to deal with the binary files in question. The file (of 7…
Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
3
votes
1 answer

NSdata writeToURL not working

i'm trying to save a NsData file into a directory. that is the code of my method: - (void)cacheImage:(NSData *)imageData withTitle:(NSString *)title { NSURL *cacheURL = (NSURL *)[[self.fileMenager URLsForDirectory:NSCachesDirectory…
Max_Power89
  • 1,710
  • 1
  • 21
  • 38
3
votes
2 answers

Not able to write nsdata in a folder

Below is the Code: NSData * imageData = [NSData dataWithContentsOfURL:imageURL]; [imageData writeToFile:savedImagePath options:NSDataWritingAtomic error:&error]; if(error != nil) NSLog(@"write error…
Mohammed Ebrahim
  • 849
  • 1
  • 12
  • 22
2
votes
1 answer

Read/Write Byte array Android

Trying to write a byte[] to a file, which i think is working correctly String filename = "BF.dat"; public void WriteByteToFile(byte[] mybytes, String filename){ try { FileOutputStream FOS = openFileOutput(filename,…
Jake Graham Arnold
  • 1,416
  • 2
  • 19
  • 40
1
2
3
24 25