file-io

Android FileWriter not working on Sony Ericsson Arc but works on another phone

a 夏天 提交于 2020-01-07 09:15:23
问题 The issue I am having could be a hardware-related. In any case I'm stumped. I have written some code (that I took and modified from: Writing Text File to SD Card fails) I've put the code below. It works fine on my Sony Ericcson X8. However, on the Sony Ericsson Arc, I can't find the file when I look for it on the phone! I went line by line through the code and there are no failures. It's as if it's on the phone and I'm just blind. I can even see in the debugger that the value of gpxfile is:

Open a file name +date as csv in Python [closed]

自闭症网瘾萝莉.ら 提交于 2020-01-07 06:24:36
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I want to be able to open a file name automatically and save it as a .csv, the files I produce are always called the same thing + todays date. For example todays spreadsheet could be called: "TODAYS SHEET" +

C# Append Timestamp to Filepath

让人想犯罪 __ 提交于 2020-01-07 05:01:29
问题 I have the following problem or question, I have this function private void SavePic(Canvas canvas, string filename) { RenderTargetBitmap renderBitmap = new RenderTargetBitmap( (int)canvas.Width, (int)canvas.Height, 96d, 96d, PixelFormats.Pbgra32); // needed otherwise the image output is black canvas.Measure(new Size((int)canvas.Width, (int)canvas.Height)); canvas.Arrange(new Rect(new Size((int)canvas.Width, (int)canvas.Height))); renderBitmap.Render(canvas); //JpegBitmapEncoder encoder = new

How do I track reading of a a file using .readLine() in java?

旧巷老猫 提交于 2020-01-07 04:54:50
问题 I am reading a file using bufferedREader ,the file is a text file with lot of text here is how I am reading it while(true) //I know the loop is not perfect just ignore it for now, i wanna concentrate on the tracking { try { br.readLine(); } catch(IOException e) { break; } catch (Exception e) { break; } } I want to track what percentage of the file I have read so I can use that percentage value in my progress bar like this: while(true) { try { br.readLine(); progressBar.setValue(percentageRead

File I/O In DrScheme

馋奶兔 提交于 2020-01-07 04:52:05
问题 (read) takes in a string from stdin, parses it as an s-expression, and returns that expression. How do I do the exact same thing, except taking input from a file? 回答1: Any of these: (call-with-input-file "foo" read) (with-input-from-file "foo" read) The first will open the file and apply read on the open port to read a value and finally close it. The second is similar, except that it applies the function on no arguments in a dynamic context where the current input is read from the file. There

Issues writing PNM P6

我的未来我决定 提交于 2020-01-07 03:26:06
问题 I'm writing a program that takes in two duplicate PNM P6 files, puts the memory of the first file into a buffer, creates a yellow diagonal line over that, and writes the result to the second file. When I run it, the output file is corrupted and can't be displayed. I noticed when looking at the output that it's missing the three lines that should be at the top: P6 1786 1344 255 I don't know how to programmatically ensure that those lines stay in the code -- I can't figure out why they're even

Multithreaded File Compare Performance

时光毁灭记忆、已成空白 提交于 2020-01-07 02:37:34
问题 I just stumbled onto this SO question and was wondering if there would be any performance improvement if: The file was compared in blocks no larger than the hard disk sector size (1/2KB, 2KB, or 4KB) AND the comparison was done multithreaded (or maybe even with the .NET 4 parallel stuff) I imagine there being 2 threads: one that reads from the beginning of the file and another that reads from the end until they meet in the middle. I understand in this situation the disk IO is going to be the

Writing an ArrayList of non-string objects to file

假装没事ソ 提交于 2020-01-07 02:15:50
问题 EDIT: I solved the problem, I forgot to close the ObjectOutputStream. 'doh! I'll leave the question just in case someone wants to propose a more elegant option, which would be much appreciated. I currently am trying to write a class called phonebook to file, which contains an ArrayList of objects called PhonebookEntry. Here is the Phonebook class: import java.util.ArrayList; import java.io.*; public class Phonebook implements Serializable private static final long serialVersionUID = 1;

Why doesn't memcpy work when copying a char array into a struct?

ⅰ亾dé卋堺 提交于 2020-01-06 20:01:29
问题 #define buffer 128 int main(){ char buf[buffer]=""; ifstream infile("/home/kevin/Music/test.mp3",ios::binary); infile.seekg(-buffer,ios::end); if(!infile || !infile.read(buf,buffer)){ cout<<"fail!"<<endl; } ID3v1 id3; cout<<sizeof(id3)<<endl; memcpy(&id3,buf,128); cout<<id3.header<<endl; } struct ID3v1{ char header[3]; char title[30]; char artist[30]; char album[30]; char year[4]; char comment[28]; bool zerobyte; bool track; bool genre; }; When I do the memcpy, it seems to be pushing too much

Why doesn't memcpy work when copying a char array into a struct?

左心房为你撑大大i 提交于 2020-01-06 20:00:11
问题 #define buffer 128 int main(){ char buf[buffer]=""; ifstream infile("/home/kevin/Music/test.mp3",ios::binary); infile.seekg(-buffer,ios::end); if(!infile || !infile.read(buf,buffer)){ cout<<"fail!"<<endl; } ID3v1 id3; cout<<sizeof(id3)<<endl; memcpy(&id3,buf,128); cout<<id3.header<<endl; } struct ID3v1{ char header[3]; char title[30]; char artist[30]; char album[30]; char year[4]; char comment[28]; bool zerobyte; bool track; bool genre; }; When I do the memcpy, it seems to be pushing too much