w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
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

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

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

How to save multiple activity's edit text into a single file and again restoring back on pressing button
Shared preference is a good idea. see this (How to use SharedPreferences in Android to store, fetch and edit values) Alternatively you think of other File IO. Android also provide XML parser that could be another option depend on your requirement i guess. For SAX see this(How to parse XML using the SAX parser)

Categories : Android

Android Menu not showing in emulator on clicking on Menu button
A very late post, but: Press the F2 key when running in the emulator to toggle display of the menu (similar to pressing the menu button on a device). The menu button on the standard emulator does not work if Android3.0+ is used as the emulated OS

Categories : Android

Writing on a already opened CSV file from R studio
For writing to files open with excel I use write.table(dataobject,file="clipboard",sep=" ") Then go to excel and do a control v, where dataobject is the data object that you want to write! This basically copies and pastes to excel

Categories : R

JQuery Mobile Menu on Android menu button
KeyEvent.prototype.menuTrigger = function() { var e = document.createEvent('Events'); e.initEvent('menuKeyDown'); document.dispatchEvent(e); } ----------------------OR------------------------------- document.addEventListener("menubutton", function () { alert('Menu button'); }, false); document.addEventListener("searchbutton", function () { alert('Search button'); }, false); document.addEventListener("backbutton", function () { alert('Back button'); }, false);

Categories : Android

Error Writing to File in Visual Studio
The variable body in this section is incorrect. body=""; ... BufferNo=sprintf(body,"%.5f %[3].5f %[3].5f %[3].5f %[3].5f %[3].5f %[3].5f %[3].5f ", a1,a2,a3,a4,a5,a6,a7,a8); Presumably it's a char * (alhtough I'm just guessing), which means you are trying to write a bunch of number values to a constant string capable of holding exactly zero characters. Since it's a constant, it's non-writeable. Change it to char body[1000]; or something similar.

Categories : C++

how to save text box values in ms word from visual studio 2010
It sounds like you have to download Open Xml SDK. Than you will be able to create a word documents from your asp page. some tutorials: http://msdn.microsoft.com/en-us/library/office/dd440953%28v=office.12%29.aspx something like this: using (WordprocessingDocument package = WordprocessingDocument.Create(docName, WordprocessingDocumentType.Document)) { // Add a new main document part. package.AddMainDocumentPart(); // Create the Document DOM. package.MainDocumentPart.Document = new Document( new Body( new Paragraph( new Run( new Text("Hello World!"))))); // Save changes to the main document part. package.MainDocumentPart.Document.Save(); } then you have to write the word document to the resp

Categories : C#

Visual Studio LESS: Compile main file upon save of imported file
According to "SLaks" comment on the Uservoice request for this feature. "Press Alt+Shift+Y (Build, Web Essentials, Recompile all LESS Files) to do this without rebuilding." I agree, it would be a great feature for it to do it automatically without the shortcut.

Categories : Visual Studio

Rendering problems while creating a menu in Android Studio
It looks you have some attributes in your menu that aren't valid - they're layout attributes, not menu attributes. Try this: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/new_game" android:icon="@drawable/magnify" android:title="New Game" android:showAsAction="ifRoom" /> <item android:id="@+id/help" android:icon="@drawable/magnify" android:title="Help" android:showAsAction="ifRoom" /> </menu>

Categories : Android

Either save state of Fragment or save file and update from that - Android
I think you are correct to try to find a simple approach to this. Case 1: You haven't posted your TabListener code, so firstly I am going to assume that you are adding fragments in onTabSelected and removing them in onTabUnselected. IF this is the case then you should look at using attach and detach instead. The difference is the same instance of the fragment will be used each time you press tab 1. Case 2: Based on what you have said (fragment 1 not being destroyed immediately) you may already using attach / detach. If this is the case, then the system may be responsible for destroying fragment 1 as part of its housekeeping. In this case, look at using setRetainInstance(true) for fragment 1. My concern about this approach is that you are updating your UI in this fragment , so you may ne

Categories : Android

Blank menu, NullPointerException in Android Studio 0.2.5 when trying to create new module
I was able to add a new module by manually creating a new folder and copy/pasting: Another module IML file (renaming it after) build.gradle file from another module creating all the Android files manually (Manifest, RES files, SRC files) Then if you restart Android Studio, it should see it a new module. This is not the best solution but a workaround in the meantime.

Categories : Android

Writing a text based game, I'm confused as to how to check input on button press and then update
You need to use an EventListener so your program can detect when the button has been pressed and check for the text in the textArea. Check out this tutorial. Here is a simple generic example: button.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { message = textArea.getText(); //Do stuff } });

Categories : Java

Parsing a text file, add text in it and save to another file - Java
I confirm the use of Scanner method. First i will parse everything and then i'll put all in an arraylist. The solution i found: Scanner s = new Scanner(new File("filepath")); ArrayList<String> list = new ArrayList<String>(); while (s.hasNext()){ list.add(s.next()); } s.close(); Then i will analyze the arraylist and modify it with some print and concatenation (due to fact that my data is regular)

Categories : Java

Save entered text in editText via button
Change your function: private void makeTag(String tag){ String or = savednotes.getString("KEY_NAME", "0");// here, '0' is default value Editor preferencesEditor = savednotes.edit(); preferencesEditor.putString("KEY_NAME",tag); preferencesEditor.commit(); } EDIT onCreate() { savednotes=PreferenceManager.getDefaultSharedPreferences(getBaseContext()); }

Categories : Android

Button to open text file won't function with text file not in class root directory
This is windows specific code, I think the problem is using the file separator "/" instad of "", try changing your code to Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "config\gameItems.txt");

Categories : Java

Change default save location of projects (or Workspace ) in Android Studio
It's simpler: if you create a project at, say /home/USER/Projects/AndroidStudio/MyApplication from there on all new projects will default to /home/USER/Projects/AndroidStudio. Android Studio: Default project directory

Categories : Android

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

trying to sort data in text box in php and save to text file
I can't be sure but I think this is what you are looking for: <html> <body> <form method="post"> <div align="center"><textarea name="mp" cols="60" rows="10">0|1|2</textarea><br /> Delim: <input type="text" name="delim" value="|" size="1" />&nbsp;data1: <input type="text" name="mail" value="0" size="1" />&nbsp;data2: <input type="text" name="pwd" value="1" size="1" />&nbsp; <input type="submit" value=" send " name="btn-submit" /> </div> </form> </body> </html> <?php if(isset($_POST['mp'], $_POST['delim'], $_POST['btn-submit'])) { //only do file operations when appropriate // separate the value into an array of newlines $delim = $_POST["delim"]

Categories : PHP

Android Map Api V2 with menu Button
@user2644575 welcome to so, for better help always post logcat try yourActivity.this instead of onClick.this Intent myIntent=new Intent(yourActivity.this,a.class); Also add SecondActivity => a inside AndroidManifest.xml like <activity android:name=".a"> </activity> inside <application> tag of AndroidManifest.xml

Categories : Android

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

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

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

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 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

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#

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 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 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

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++

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#

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 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 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

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#

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

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++



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