file-io

how to reset (clear) file input

試著忘記壹切 提交于 2019-12-29 08:27:13
问题 how can I reset file input in IE, I used the following and it worked in chrome and FF but not IE fileInputElement.value="" what's the alternative in IE ? 回答1: If fileInputElement is on its own in the form fileInputForm , you can do: window.fileInputForm.reset(); Otherwise for IE you'll have to replace the element with a clone: fileInputElement.parentNode.replaceChild( fileInputElement.cloneNode(true), fileInputElement ); 回答2: SOLUTION The following code worked for me with jQuery. It works in

java.io.StreamCorruptedException: invalid stream header: 00000001

此生再无相见时 提交于 2019-12-29 08:23:14
问题 I keep getting this get this Exception : java.io.StreamCorruptedException: invalid stream header: 00000001 Server side I used this to send and receive int, works fine. Server: new DataOutputStream(player1.getOutputStream()).writeInt(P1); Client: dataFromServer = new DataInputStream(socket.getInputStream()); dataFromServer.readInt(); But when I try to send an object, like this, it gives the error. Server: new ObjectOutputStream(player2.getOutputStream()).writeObject(gameCrossword); Client:

inserting data in the middle of a text file through java

断了今生、忘了曾经 提交于 2019-12-29 08:05:07
问题 I want to insert the data at some positions in the text file without actually overwriting on the existing data.I tried RandomAccessFile ....but that also overwrites it.... Is there any way to insert the data without overwriting?? -Thanks in advance 回答1: You have to read your file and rewrite it. During this operation you have to find the place where you want to put your text and write it. 回答2: It is not possible (not with Java, and not with any other programming language) to "just" insert

How can I limit file fragmentation while working with .NET?

房东的猫 提交于 2019-12-29 07:57:09
问题 In my application I am gathering small data bits into a bigger file over time. As a result, the target file becomes excessively fragmented. What can be done to limit fragmentation of the output file with .NET? 回答1: You could deliberately increment the file size in larger chunks and internally monitor where the end of your current usage is. That way you give the system a better chance of allocating contiguous space for your file. 回答2: The only way you can reliably reduce file fragmentation is

Java - Parsing Text File

Deadly 提交于 2019-12-29 07:56:11
问题 I have an input text file in this format: <target1> : <dep1> <dep2> ... <target2> : <dep1> <dep2> ... ... And a method that takes two parameters function(target, dep); I need to get this parsing to call my method with each target and dep eg: function(target1, dep1); function(target1, dep2); function(target1, ...); function(target2, dep1); function(target2, dep2); function(target2, ...); What would be the most efficient way to call function(target,dep) on each line of a text file? I tried

MATLAB how to write header in text file

邮差的信 提交于 2019-12-29 07:56:09
问题 How to write a text header in text file? for example in the example below, how to write the header code salay month just once? Code Salary Month 12 1000 12 14 1020 11 11 1212 9 The code: fid = fopen('analysis1.txt','wt'); for i=1:10 array = []; % empty the array .... array = [code salary month]; format short g; fprintf(fid,'%g\t %g\t %g\n',array); % write to file end fclose(fid); 回答1: Is there any reason for not using simple solution like following? ... fid = fopen('analysis1.txt','wt');

Local Chrome extension to set file of input type=“file”

那年仲夏 提交于 2019-12-29 07:50:09
问题 I'am developing an Extension for Chrome browser. I wan't to choose a file from a input type="file" html element using the extension. But I know this is not possible due to security restrictions. Is there a way to remove the security restrictions of Chrome related to this issue so that this will be possible. Thanks. 回答1: Ok i'm going to answer my own question. First of all thank Michael Dibbets and wtjones for your answers. --disable-web-security and --allow-file-access-from-files did not work

read .yml files in matlab

你。 提交于 2019-12-29 07:43:32
问题 I would like to read .yml files in Matlab. These files contain coordinates x and y of key points on a face image. I looked for different tools but I don't seem to find any answers. My .yml files look like this YAML:1.0 Image file: "00032009.jpg" Contours count: 8 Contours: - Name: FO Count: 41 Closed: 0 Points: - x: 682.5947265625000000 y: 743.1998901367187500 - x: 685.9638061523437500 y: 771.3800659179687500 ...... and so on Note 00032009.jpg is an image of a face x and y are coordinates of

Write file into disk using JSF 2.2 inputFile

↘锁芯ラ 提交于 2019-12-29 07:22:48
问题 I'm trying to upload an image file using h:inputFile tag and write it to disk. My JSF code: <h:form id="fileUploadForm" enctype='multipart/form-data' prependId="false"> <h:inputFile value="#{solicitacaoManagedBean.imagemCarregada}" /> <br /> <h:commandButton styleClass="btn btn-primary " value="Enviar" action="#{solicitacaoManagedBean.enviarImagem}" /> </h:form> My ManagedBean: @Named(value = "solicitacaoManagedBean") @SessionScoped @MultipartConfig(location = "/home/rogerio/tmp/") public

How to import a Text file content to a JTextArea in a Java application?

时光怂恿深爱的人放手 提交于 2019-12-29 07:22:12
问题 how to import a Text file content to a JTextArea in a Java application using JFileChooser? 回答1: should be something like the following code: JFileChooser chooser = new JFileChooser(); int returnVal = chooser.showOpenDialog(null); //replace null with your swing container File file; if(returnVal == JFileChooser.APPROVE_OPTION) file = chooser.getSelectedFile(); } JTextArea text = new JTextArea(); BufferedReader in = new BufferedReader(new FileReader(file)); String line = in.readLine(); while