w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Javascript Text Editor in UIWebView using execCommand
The following works in Chrome, Safari, Firefox, and Opera, and even Internet Explorer 9: <input type="button" onclick="document.execCommand('forecolor', false, '#407ec9');" value="Change" /> <div contenteditable="true">Test</div> http://jsfiddle.net/M5j8b/ It also works in Mobile Safari in iOS 6. I'm not seeing anything obviously wrong with your stringByEvaluatingJavaScriptFromString call. I suspect something isn't being escaped properly. I would try making a simple JavaScript function on the page and call it instead: function foo() { document.execCommand('forecolor', false, '#407ec9') } If that doesn't work, I suspect a different problem.

Categories : Javascript

Node-Webkit SaveAs File Dialog only triggers for unique file names?
Without seeing more of your code, I'll hazard a guess and suggest : jQuery('#export_file').trigger('change'); Hope this helps, Jonathan "Windows App Creation with node-webkit"

Categories : Javascript

Excel.Workbook.SaveAs(...) with a same name file
try using File object's Exists method: if (!System.IO.File.Exists(@"C: est2.xls")) { xlWorkBook.SaveAs(@"c: est2.xls"); } else { xlWorkBook.SaveAs(@"c: est2(Copy).xls"); } Or Alternatively you can overwrite your excel file by Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); excel.DisplayAlerts = false; excelSheePrint.SaveAs(filename, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, true, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing); Note: It will overwrite the existing excel (if exist) without asking the user.

Categories : C#

Difference in lighting between "file -> save as" and "saveas"
Found the answer here. Turns out there is another function that is called when you do "file -> save as"

Categories : Matlab

Photoshop Javascript script: Rename file and saveAs
Try to use forward slashes in your docPath: var docPath="C:/Users/user/Desktop/test"; (tab) and u (beginning of a Unicode sequence) have special meanings in JS strings. Or you can escape them, of course: var docPath="C:\Users\user\Desktop\test";

Categories : Javascript

Writing a text file using python
with open('somefile.txt', 'w') as fp: fp.write('''MY_FILE = E: est.jpg BAND_SUBSET = ( 1 0 0 ) SPATIAL_SUBSET1 = ( 25.0 50.0 ) SPATIAL_SUBSET2 = ( 25.0 50.0 ) PARA1 = ( 0.0 0.0 0.0 0.0 0.0 0.0 ) END = END''')

Categories : Python

writing to text file using BufferedReader
As per your problem statement, you need to take input from a file, do some processing and write back the processed data in the same file. For this, please note the below points: You may not create a file with same name in a directory, so you must create the new file at some other location; or write the content into different file and later rename it after deleting original one. While your file is open for reading, modifying the same file is not a good idea. you could use below approach: Read the content of the file and store in a data structure liek Arrays, ArrayList. Close the file. Process the data stored in the data structure. Open the file in write mode (over-write mode rather than append mode) Write back the processed data into the file.

Categories : Java

Writing a table in a text file
Use csv.writer to write CSV-style data to files. Example: import csv import re pattern = re.compile('([0-9]*:[0-9]*:[0-9]*) Current Track Playing = ([^-]*?) - ([^-]*)$') csv_file = open('music.csv', 'wb') csv_writer = csv.writer(csv_file, delimiter=';', quotechar='"', quoting=csv.QUOTE_MINIMAL) with open('music.log', 'r') as music_log: for line in music_log: timestamp, song, artist = pattern.match(line.strip()).groups() csv_writer.writerow([timestamp, song, artist]) csv_file.close() (This assumes you've already done the stripping of the numerical IDs from the log you asked about in another question). Output: 08:04:10;Skinny Genes;Eliza Doolittle 08:07:09;Keep On Walking;Scouting For Girls

Categories : Python

Continuously writing to a text file in Android
At time of writing your link appears to be for a different language, and that version seems to be down. The English version is still up and can be found here: http://developer.android.com/training/basics/data-storage/files.html In the meantime, I believe you have to access the raw directory which contains your text file (create a raw directory within the res directory if you don't already have one and put the text file there). The code to access the text file is getResources().openRawResource(resourceName) (as stated in this question: http://stackoverflow.com/a/2856501/555544) - I believe resourceName is the id of your text file as stated in your R file (e.g.: R.raw.foo) - this is how Android can find files in your directories. Then, just do your file I/O as you normally do. Let me know

Categories : Java

Writing post values to a text file
This works completely on my localhost. I haven't recreated the full scenario with your HTML but it works now. Just remember to set the file permissions to read/write and also make sure you do it one step at a time. For example, start off with this code and make sure you get the file name file.txt with the text you wanted. Then take it to the next level by including the HTML bit. <?php $fname = "Skippy"; $message = "name is :" . $fname. " "; $file = 'file.txt'; $fd = fopen($file, "a"); if ($fd) { fwrite($fd, $message . " "); fclose($fd); } ?>

Categories : PHP

Writing text to txt file in python on new lines?
How about something like this: import urllib2 url = 'http://www.google.com' data = '' try: data = urllib2.urlopen(url).read() except urllib2.URLError, e: data = 'PAGE 404: It Doesnt Exist ' + e with open('outfile.txt', 'w') as out_file: out_file.write(data)

Categories : Python

Fix newlines when writing UTF-8 to Text file in python
If you use python 2, then use u" " to append newline, and encode internal unicode format to utf when you write it to file: file_object.write((n+u" ").encode("utf")) Ensure n is of type unicode inside your loop.

Categories : Python

Writing Ints, floats to a text file
C++ streams don't work with format strings like printf does. Either just use printf: sprintf(buffer, "U heeft nu deze 2 formules gekozen: " "Formule 1: %dx + %dy = %0.1f. " "Formule 2: %dx + %dy = %d", x1Int, y1Int, r1Int, x2Int, y2Int, r2Int); stream << buffer; or to stay with streams alone: stream << "U heeft nu deze 2 formules gekozen: Formule 1: " << x1Int << "x + " << y1Int << "y = " << r1Int << ". Formule 2: " << x2Int << "x + " << y2Int << "y = " << r2Int; It is a bit weird that you have a floating point format %0.1f, but the variable you're matching it with is called r1Int. Be careful for undefined behaviour.

Categories : C++

Writing to text file with automatic spacing
Try padding the strings using String.format() This question should show you how it works: How can I pad a String in Java? Pad each of the elements into strings of equal length before you write to the file.

Categories : Java

Bugs in reading and writing to text file
In the writer method you're closing the file output stream: fos.close(); But surely you should be closing the print stream instead. prntst.close(); Closing the print stream will flush the stream and then close the underlying output stream. When you close the output stream, it won't know anything about the print stream constructed on top of it, so won't know to flush it.

Categories : Java

String Writer writing into text file
The issue is in Submit Code protected void btnShow_Click(object sender, EventArgs e) { System.IO.StreamWriter stringWriter= new System.IO.StreamWriter("c:\test.txt"); foreach (Control control in Panel1.Controls) { var textBox = control as TextBox; if (textBox != null) { if (string.IsNullOrEmpty(textBox.Text)) { textBox.Style["visibility"] = "hidden"; } stringWriter.Write( textBox.Text+","); // Write text to textfile. } // end of if loop } Reference MSDN and MSDN

Categories : C#

How to change the fontsize when writing to a text file
Supposing you are editing your text in a JTextArea you might do this: this.textArea.setFont(new Font("Arial", Font.PLAIN, 12)); //the code comments itself if you want bold then write Font.BOLD As someone already told you, unfortunately plain .txt files don't contain formatting. If you need to format the text, you should change format and try HTML.

Categories : Java

Writing a fixed-width text file
I would recommend using the new .NET methods for string manipulation rather than the old-style VB6 functions, for instance: Private Function ToLen(text As String, length As Integer) If text.Length > length Then Return text.SubString(0, length) Else Return text.PadRight(length) End If End Function Then, when you are writing to the file, don't concatenate the strings together. It would be more efficient to call Write multiple times: Using MyFile1 As New StreamWriter("C:TempMyFile.txt") Do ' loop through records MyFile1.Write(ToLen(Item1, 10)) MyFile1.Write(ToLen(Item2, 50)) MyFile1.WriteLine(ToLen(Item3, 25)) Loop End Using

Categories : Vb.Net

StreamWriter Replace while Writing to a new Text File
You can replace a character with a string by simply converting the character to a string and then calling the Replace(string, string) overload. For instance: wwrite.WriteLine((i + 1).ToString() + "^" + listView1.Items[i].SubItems[3].Text.Replace("x0A", " ")); You seem to be confused about strings. Strings are simply a collection of characters. So " " and ' ' are essentially the same value. The first stores the value as a single character string and the second stores the same value as a character. If you want to replace a new-line character with the actual string (as two separate characters), you need to escape the backslash, for instance: s = s.Replace(" ", "\n"); Or: s = s.Replace(" ", @" ");

Categories : C#

How to add a break to a line while writing to a text file
Your underlying QIODevice (the file) is not really working in text mode. Use QIODevice::Text when opening the file that is used with the stream QFile file( filename , QIODevice::Text ); ... QTextStream stream( &file); For a text stream, both " " and ' ' should work. You may opt for std::endl (or, more precisely, its counterpart in Qt) instead, but this is not really necessary. " " and ' ' will produce proper result regardless of the OS, assuming your output stream is indeed a text stream, and assuming that your generate file on the same platform that you use to inspect it. (The remarks asserting that " " must be used on Windows are incorrect.) An example of a situation when you indeed will have to use " " is when you are trying to generate a Windows text file on a POSIX system.

Categories : C++

Writing Styled Text to a .docx file
For my example I assume you'd use a HTMLEditorKit in your JTextPane. I would then parse the StyledDocument of the pane and set the textruns accordingly. Of course this is just a starter, you'd need to parse all the possible styles and convert them yourself in the loop below. I've to admit, that I've never done something with the HTMLEditorKit and therefore I don't know how to handle the CSS.CssValues properly. import java.awt.Color; import java.io.FileOutputStream; import java.lang.reflect.Field; import java.util.Enumeration; import javax.swing.*; import javax.swing.text.*; import javax.swing.text.html.*; import org.apache.poi.xwpf.usermodel.*; public class StyledText { public static void main(String[] args) throws Exception { // prepare JTextPane pad = new JTextPa

Categories : Java

Writing to text file doesn't match
I think that you should increment recordsWritten in the last step: if (numberofCommas > 8) { stringWriter.Write(textBox.Text); numberofCommas = 0; recordsWritten++; } Here is a better way to do it using Linq: var textBoxes = Panel1.Controls.OfType<TextBox>().Select((t, i) => new { TextBox = t, Index = i }).ToList(); foreach (var tb in textBoxes) { if (string.IsNullOrEmpty(tb.TextBox.Text)) tb.TextBox.Style["visibility"] = "hidden"; tb.TextBox.Enabled = false; } foreach (var line in textBoxes.GroupBy(e => e.Index / 10) .Select(e => string.Join(", ", e.Select(a => a.TextBox.Text).ToArray()))) stringWriter.WriteLine(line);

Categories : C#

Writing a Tokenized string into a text file?
You need to write() each token, append it with System.getProperty("line.separator"). A sample code will be : while( stnz2.hasMoreTokens()){ fw.write(stnz2.nextToken()+System.getProperty("line.separator")); } Or, you can decorate your FileWriter with a PrintWriter and use its println() method for formatting.

Categories : Java

Writing packet information into text file
Probably because you are missing a comma before " ": ---------------------------------------------------vv----- file:write(tostring(srcadd), " ", tostring(dstadd), " ") It may be useful to check for file value returned by the open call. I don't see any other problems with the script; if you still have issues, I have a page on debugging Wireshark Lua scripts that may help.

Categories : Networking

writing new lines to a text file in powershell
`n is a line feed character. Notepad expects linebreaks to be encoded as `r`n (carriage return + line feed, CR-LF). Open the file in some useful editor (SciTE, Notepad++, UltraEdit-32, Vim, ...) and convert the linebreaks to CR-LF. Or use PowerShell: (Get-Content $logpath | Out-String) -replace "`n", "`r`n" | Out-File $logpath

Categories : Powershell

Exporting PDF's from SQL Server DB and writing a Map to a Text File
when I finally finished researching all the different approaches to the problem, it was really quite simple to code. I did not use BCP at all. I created Variables for the information that I was extracting that I wanted inside the Text File. Filename Date (From SQL Table for the Original Creation Date) Case Number (internal Identifier for the 3rd party program to link to) Description (Taken from the SQL Table to describe the document) Then I put the application to work Writing the Code to PDF one at a time using (SqlConnection Conn = new SqlConnection(strSQLConn)) { //open the connection Conn.Open(); Console.WriteLine("the connection is open"); //Variables needed for looping DateTime Today = System.DateTime.Now;

Categories : C#

Writing text to flat file using spring batch
You can simply write a class implementing FlatFileFooterCallback interface or just use default implementation SummaryFooterCallback class. http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/file/FlatFileFooterCallback.html

Categories : Spring

Writing information on an always readable text file with Python
Have you tried this? new_text = str(distance0)+","+str(time0)+","+str(distance1).....) print new_text text_file = open("sensor_file.inc","rw") previous_text = text_file.read() total_text = previous_text + new_text text_file.write(total_text) text_file.close() This reads the data previously on the file, appends the new data to this and rewrites the data back to the file. Hope this helps!

Categories : Jquery

Which is faster: Writing SQLite database or In a Text File
It depends. If you're saving complex data, then SQLite Database is obviously better and scalable. But if you're saving non complex data like an integer or something, by all means use a text file, afterall SQLite Database is a flat file

Categories : Android

Writing a specific listview tag property to a text file
Here you have a corrected version of your Sub performing the actions you want: Public Sub RemoveUser(ByVal name As Object) If _mainView.lvwChannelUsers.InvokeRequired Then _mainView.lvwChannelUsers.Invoke(New ParameterizedThreadStart(AddressOf RemoveUser), name) Else Dim lvi As ListViewItem = _mainView.lvwChannelUsers.FindItemWithText(DirectCast(name, String)) Dim FILE_NAME As String = Application.StartupPath & "accounts" & DirectCast(name, String) Dim objWriter As New System.IO.StreamWriter(FILE_NAME) objWriter.Write(lvi.Tag) objWriter.Close() _mainView.lvwChannelUsers.Items.Remove(lvi) End If End Sub

Categories : Vb.Net

Reading and Writing text file in Azure Storage
Replace the following line of code: using (var memoryStream = new MemoryStream()) { memoryStream.Write(System.Text.Encoding.UTF8.GetBytes(firstString), 0, System.Text.Encoding.UTF8.GetBytes(firstString).Length); blockBlob.UploadFromStream(memoryStream); } with using (var memoryStream = new MemoryStream()) { memoryStream.Write(System.Text.Encoding.UTF8.GetBytes(firstString), 0, System.Text.Encoding.UTF8.GetBytes(firstString).Length); memoryStream.Position = 0; blob.UploadFromStream(memoryStream); } What's happening is that when you write the byte array to memoryStream, you're not resetting the position of stream to 0 thus a 0 byte blob is being uploaded.

Categories : Azure

Writing from multiline text box to .txt file, and then reading it back
You can rely on the Lines Property in case of having more than one line. Sample code (curTextBox is the given TextBox Control): Using writer As System.IO.StreamWriter = New System.IO.StreamWriter("path", True) Dim curLine As String = curTextBox.Text If (curTextBox.Lines.Count > 1) Then curLine = "" For Each line As String In curTextBox.Lines curLine = curLine & " " & line Next curLine = curLine.Trim() End If writer.WriteLine(curLine) End Using NOTE: this code puts in one line all the text from the given TextBox independently upon its number of lines. If it has more than one line, it includes a blank space to separate the individual lines (all of them fitting in a single line of the file anyway). You might want to cha

Categories : Vb.Net

Will Log writing in text file affect performance of a website?
Hmm, the impact is most likely not going to be affected. At least not noticeable is long as your are not logging to much. You should look at a logging framework like log4net. It will do alot of things for you, like writing to the txt file after a given amount of logs. This will reduce the amount writes to a file. If you want to do it yourself I would recommend performing the log on another thread, like this: var thread = new Thread(message => { // write message to txt file. }); thread.Start("This is a log statement"); This way it won't occupy your main thread. However, writing to a file is quite dangerous using multiple threads. You'll need some locking: private static readonly object _writeLock = new object(); var thread = new Thread(message => { l

Categories : C#

writing in a text file OpenCV visual studio
std::ofstream f("C:/file_to_write_to.txt"); // writing element my_matrix[10, 10] to file. assuming it's a float. f << my_matrix.at<float>(10, 10) << std::endl; f.close();

Categories : Opencv

Writing to text file. Go to new line after hitting certain length
i want it to go next line after hitting the 4th comma . How do i do it? You could keep track of the number of commas you have written so far and once the counter reaches 4 simply reset it to 0 and add a new line to the file: protected void btnShow_Click(object sender, EventArgs e) { using (var writer = new StreamWriter(Server.MapPath(@"~/Puzzle/puzzle.txt"))) { int recordsWritten = 0; foreach (Control control in Panel1.Controls) { var textBox = control as TextBox; if (textBox != null) { if (string.IsNullOrEmpty(textBox.Text)) { textBox.Style["visibility"] = "hidden"; } stringWriter.Write(textBox.Text + ","); record

Categories : C#

actionscript 3.0 writing all array data into text file
Is it possible that you mean this code, it's working properly var names: Array = ["word1", "word2", "word3"]; var file: File = File.applicationStorageDirectory.resolvePath("allnames.txt"); var fileStream: FileStream = new FileStream(); fileStream.open (file,FileMode.WRITE); for (var i:uint=0; i<names.length; i++) { fileStream.writeUTFBytes (names[i]+" "); } fileStream.close ();

Categories : Arrays

Writing user input to a text file in python
Start here: >>> mydata = ['Hello World!', 'Hello World 2!'] >>> myfile = open('testit.txt', 'w') >>> for line in mydata: ... myfile.write(line + ' ') ... >>> myfile.close() # Do not forget to close EDIT : Once you are familiar with this, use the with keyword, which guaranties the closure when the file handler gets out of scope: >>> with open('testit.txt', 'w') as myfile: ... for line in mydata: ... myfile.write(line + ' ') ...

Categories : Python

An error occured while writing into a text file from Android app
Make sure you have: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> in your manifest as well. package com.example.fileio; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.widget.TextView; public class FilioActivity extends Activity { private TextView tv; private static final String TAG = "MEDIA"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv = (TextView) f

Categories : Java

Writing to a text file if username doesn't exist
Please forgive apparent criticism but there are a lot of issues with your code and I think it will help if I point out some poor practices first: Don't keep reassigning variables. Just use them as $_POST['whatever'] there is no advantage in copying them into other memory intensive structures. It obfuscates rather than clarifying your code. DO NOT EVER store credit card details in a plain text file. Why are you using a custom CSV data structure? This is what databases are for XML at a pinch. You test for username existence twice, neither in the right place to fix the problem. For your answer: if (!empty($username) && !empty($password) && !empty($firstname) && !empty($lastname) && preg_match($emailaddress, $email)

Categories : PHP

Removing blank line at end of string before writing to text file?
Use the Write method instead of WriteLine. The WriteLine method is the one adding a blank 0 length line to the file because it is terminating the "Hello World" string with a newline. writeString.Write("Hello World")

Categories : Vb.Net



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.