w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
C++ reading structs by field and writing struct directly to a stream
Yes, your code could result in invalid values being read in, due to possible padding between struct fields. Let's use the example of your struct StructOfInts, and imagine that the compiler inserts some padding between the fields, like so: byte | 0 1 2 3 | 4 5 | 6 7 8 9 | 10 11 12 13 value | field a | padding | field b | field c Then when you write the struct to the stream, you could end up with something like byte | 0 1 2 3 | 4 5 | 6 7 8 9 | 10 11 12 13 char | 'a' | '?' '?' | 'b' | 'c' if the fields contained (respectively) the values (int)'a', (int)'b', (int)'c'. Then when you read the values back in, it would look like myStruct->a = int version of 'a' myStruct->b = int version of '?' '?' myStruct->c = int version of 'b' which is obvi

Categories : C++

Delay in playing video file from Input Stream
This delay is due to writing data to temporary file.Instead you can use ParcelFileDescriptor to avoid writing to a temporary file.You can use link(http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system) as reference.

Categories : Android

Playing RTSP Video stream with authentication Android
You can set your headers manually when using setDataSource (Context context, Uri uri, Map<String, String> headers). I'd guess (never worked with RTSP, yet) that you need an "Authorization" header with a base64-encoded username and password combination.

Categories : Android

Reading multiple XML files from an input stream Java
After un-compressing (gzip) you still need to un-tar. The java JDK doesn't have a built in API for tar, but there are several available from third parties. See this answer: How do I extract a tar file in Java?

Categories : Java

How to update an XML document by stream reading a file and simultaneously stream writing output
Use SAX parser instead of DOM. You can also use the StAX APIs (part of JDK package javax.xml.stream ). Further reading- http://docs.oracle.com/javase/tutorial/jaxp/sax/parsing.html http://download-llnw.oracle.com/javase/6/docs/api/index.html?javax/xml/stream/package-summary.html

Categories : Java

Multiple sound files not playing on android phone
Most mobile devices require (for HTML5 Audio) direct user interaction and that the call to .play() be called in the same callstack as that interaction. You should be able to call .play() on another audio when one audio triggers its ended event as well.

Categories : Android

Read input stream onMainThreadException Android
I think android.os.NetworkOnMainThreadException Solution is.... Add: StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); in your class, and ADD this to ManiFestFile: <uses-permission android:name="android.permission.INTERNET"/>

Categories : Android

Android Media player throwing error (-38, 0) after doing a reset() while playing files stored on the sd card
I get the same error. I found the root reason: After MediaPlayer.reset,use getDuration and getCurrentPosition methods. Please refer to: http://developer.android.com/reference/android/media/MediaPlayer.html where you can find: There is a subtle but important difference between a newly constructed MediaPlayer object and the MediaPlayer object after reset() is called. It is a programming error to invoke methods such as getCurrentPosition(), getDuration(), getVideoHeight(), getVideoWidth(), setAudioStreamType(int), setLooping(boolean), setVolume(float, float), pause(), start(), stop(), seekTo(int), prepare() or prepareAsync() in the Idle state for both cases. If any of these methods is called right after a MediaPlayer object is constructed, the user supplied callback method OnErrorLis

Categories : Android

How can I use pdfk fill_form without writing to a temp file
Can anyone tell me why it doesn't work on the hosting provider and how I can fix this issue. I am under the impression that it is a security issue. My guess is you simply don't have write permission in the required directory. You create your temporary file in the current working directory (.). Depending on your hosting provider and the HTTP server configuration, the current working directory is not necessary what you think nor writable. Especially since your program will probably run with the www or nobody identity. I assume you have to create and then adjust the permissions on your "temporary" directory -- or use a "world writable" location such as /tmp. Finally, you have a relative path that move "upward" in your program: ./../../reports/TEST.pdf fill_form There is little ch

Categories : Mysql

Writing to temp directory when app launched via "Open with"
Please read carefully the documentation of the GetTempPath function The path specified by the TMP environment variable. The path specified by the TEMP environment variable. The path specified by the USERPROFILE environment variable. The Windows directory So there is a change, that the windows directory gets selected as temp path... Also, please verify that your application has a valid Vista manifest! If this is not existend, then several redirections and virtualisation will happen with your application: <?xmlversion="1.0" encoding="utf-8" ?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="a

Categories : Windows

How to stream MP4 and AAC format files on android over RTSP
VitamioBundle helped me achieve the above. http://www.vitamio.org/en/ Although I have not tested it on many devices, but it works on my Samsung GT-S5830

Categories : Android

Writing dummy contents in files of external storage android
File root = android.os.Environment.getExternalStorageDirectory(); File[] files = root.listFiles(); for ( File f : files ) { if (f.isDirectory()) continue; //write here }

Categories : Android

how to display image directly from httpwebresponse stream in asp.net?
You can use HttpResponse.WriteFile method to send the stream to client directly. Writes the specified file directly to an HTTP response output stream. You can create the IHttpHandler to send the stream, thus avoid some page life circle, increase the performance. Here is the link

Categories : C#

Benefit of putting Image stream directly in css
No, it's not a good idea to put your images right in the css. Browsers cache things anyway so except during the first load it won't make anything faster. Not to forget the horrible mess you get by putting image data in your CSS... Additionally, when you send proper caching headers and maybe even use timestamped URLs (i.e. the mtime of the resource is part of its URL) you can tell browsers to cache everything for a long time and when you change something it will be reloaded from the server.

Categories : CSS

Playing a multi-track file/stream using libvlc (ubuntu)
Can you be more specific about what you're trying to do ? The code in the question does not compile, cannot enumerate tracks in any stream. Below are the minimal changes for that code to become meaningful. #include <vlc/vlc.h> #include <unistd.h> #include <stdlib.h> int main( int argc, char **argv ) { libvlc_instance_t *inst; libvlc_media_player_t *mp; libvlc_media_t *m; if ( argc < 2 ) { fprintf( stderr, "Please provide a file name to open. " ); exit( 1 ); } inst = libvlc_new( 0, NULL ); m = libvlc_media_new_path( inst, argv[1] ); mp = libvlc_media_player_new_from_media( m ); libvlc_media_release( m ); libvlc_media_player_play( mp ); sleep( 1 ); libvlc_track_description_t *track_desc = libvlc_v

Categories : C

How to read audio stream that our system (PC soundcard or speakers) is playing in java
This has been asked many times. The answer is that the feature you want is not supported by Java (in fact, it is hard todo in any environment). This is not unreasonable since some operating systems don't support it. Your options are: use a cable to connect the PCs output to its input. If you use an analog cable this will introduce some noise. Use software like soundflower (mac only) to create a virtual cable. Use JNI to access a low-level API for your system that can do it.

Categories : Java

Directly writing into already connected CBPeripheral without re-discovering it
Most probably the bluetooth stack has been reset or for some other reason your peripheral became invalid. You need to monitor the state updates and if ever you receive OFF or RESETTING, then invalidate all your handles to peripherals and characteristics. Generally it is better to keep reference to the peripheral only and look up the characteristics when you need them. CoreBluetooth is going to cache them for you, so the lookup will be very fast. This answer shows you how to do that: http://stackoverflow.com/a/18091617/768935

Categories : IOS

How to fix creating a buffer and Writing it directly to disk (WriteFile)
the INT type could only be a 2 byte number from 0 - 65536 unsigned. replace all INT types with LONG (long) to start with...Not sure what compiler environment you are in though - as this change may not apply

Categories : C

Grails: writing HQL query when domains are not directly matched
Try something like this: Organization.executeQuery("select o from Organization o, Logging l where o.name like = :orgName AND o.id=l.organization_id", [orgName : orgName ]) I didn't tried it, if it works then more search options can be added on the query, and also % can be added on the parameter, in order to enhance the search.

Categories : Grails

Is it smarter to stream in large strings from an external .txt file, or to simply code them directly in?
It's always better to have it in a separate file, preferably in the JAR itself, so you can easily reach it with getResourceAsStream(). You can then easily edit this file without messing with code, and you can also modify it after the app is compiled to JAR. It's a good practice to divide logic from data, in general. Here are some methods from my FileUtils class you might like: public static String streamToString(InputStream in) { BufferedReader br = null; StringBuilder sb = new StringBuilder(); String line; try { br = new BufferedReader(new InputStreamReader(in)); while ((line = br.readLine()) != null) { sb.append(line + " "); } } catch (IOException e) { Log.e(e); } finally { if (br != null) {

Categories : Java

Practical Use to Temp Files
The two reasons I know of: As storage space for large chunks of memory you don't need at the moment, when doing memory-intensive tasks like video editing A kind of hacky way of interproccess communication

Categories : Java

How to delete temp files on app crashes
After each successfull update of cache, I save status to preferences. On Application start if status represent potentional corruction of data I clean it. Thats much more reliable then tryin to clean on crash.

Categories : Android

vagrant Temp files on windows
Assuming those are saved states / snapshots : The safest bet is to move the files, then select "Discard save state" from VirtualBox. Start up vagrant (power it up) and you'll probably be fine. If not, just point the VM back to the save states.

Categories : Windows

C++ Multiple writing points stream
In order of increasing complexity: First, just use different variables for each of the places you may want to write. Then stitch the data you put in each stream together when done. As a second level of complexity, store a std::tuple< std::ofstream, std::ofstream, std::ofstream > straems, then use std::get<0>(streams) to get the first one. If you want names, use an enum { first_stream, second_stream_name, third_stream_name } and pass that to std::get. For the most complex answer... well, it is a mess. First Template metaprogramming boilerplate: template<typename T, typename Tags, typename=void> struct index_of {}; template<typename T, template<typename...>class Pack, typename Tag0, typename... Tags> struct index_of<T, Pack<Tag0, Tags...>, typen

Categories : C++

Safely writing bytes to stream
The conversion from unsigned char to char and back is perfectly fine, and it's exactly what you should be doing. All three char types are layout compatible. You only have to be careful with any non-char integral types and convert them to uint8_t first before converting to char, etc., and similarly in the other direction.

Categories : C++

How to format a Xml-Stream for writing into file
XmlWriterSettings.Indent provides the core of a mechanism here, so it a matter of ensuring that the whole content does not need to be loaded (but some careful testing with performance counters running is definitely advisable. Just one component too eager to read data in could lead to large address space and commit usage. Therefore with data sizes of the order of 500MB I would ensure this is built for x64 only—no AnyCPU builds. So something like: void FormatXmlToFile(FileStream input, string outputFile) { using (var output = new FileStream(outputFile, FileMode.CreateNew)) { var reader = XmlReader.Create(input); var writerSettings = new XmlWriterSettings { Indent = true }; using (var writer = XmlWriter.Create(output, writerSettings)) {

Categories : Xml

Edit a configuration file w/o temp files
Looks like a case for sed -i since you're on Linux. Also, since this is system administration work, preserve a backup. sudo sed -i.bak -e '1i set eventqueue basedir /etc/monit/eventqueue/ slots 1000 set mmonit http://monit:monit@xxx.xxx.xxx.xxx:8080/collector set httpd port 2812 and use address ec2-xxx.xxx.xx.xx.com allow localhost allow 0.0.0.0/0.0.0.0 allow admin:swordfish ' /etc/monit/monitrc This says 'insert the following lines before line 1'...and the lines continue up to and including the one without a backslash at the end. You can also do the edit of the set daemon line too, even though you said it was out-of-scope: sudo sed -i.bak -e '1i set eventqueue basedir /etc/monit/eventqueue/ slots 1000 set mmonit http://monit:monit@xxx.xxx.xxx.xxx:8080/collector set httpd

Categories : Linux

The Stupid Assembly and Temp ASP.NET files story
The Temp folder is used for assembly shadow copying as described here. It is basically to avoid locking the assemblies and allow their in-place update.

Categories : C#

writing json data to request stream
I used RestSharp from the nuget installer. On reading the last paragraph, are you trying to send text data to a GET method? If so, I ended up using POST method to simulate GET method that had an object required to send over as a parameter. Perhaps this is what you need to do?

Categories : Dotnet

Effects on Input Variable after Failed Input Stream
You get zero because you have a pre-C++11 compiler. Leaving the input value unchanged on failure is new in the latest standard. The old standard required the following: If extraction fails, zero is written to value and failbit is set. If extraction results in the value too large or too small to fit in value, std::numeric_limits::max() or std::numeric_limits::min() is written and failbit flag is set. (source) For gcc, you need to pass -std=c++11 to the compiler to use the new behavior.

Categories : C++

Preserving character encoding when writing XElement to Stream
After digging into the documentation a little deeper than I had before, I found the answer. The XDocument class has a property called Declaration, which is of type XDeclaration. The XDeclaration object has a property called Encoding which has the information I need. I just need to persist that property so I can pass it to the XmlTextWriter constructor.

Categories : Xml

Writing PDF binary file from stream yields malformed PDF
Well, although the code was basiclly correct, putting it inside "eval" somehow ruined thd PDF. I still don't understand why, but deleting the eval solved the problem. The perl is called from a context of ext_filter module of Apache. I'll farther investigate this and update when I'll find an explanation for this. Thanks for everyone.

Categories : Linux

HttpListener writing data to response output stream
You will need to create a thread and stream your data to response. Use something like this: in your main thread: while (Listening) { // wait for next incoming request var result = listener.BeginGetContext(ListenerCallback, listener); result.AsyncWaitHandle.WaitOne(); } somewhere in your class: public static void ListenerCallback(IAsyncResult result) { var listenerClosure = (HttpListener)result.AsyncState; var contextClosure = listenerClosure.EndGetContext(result); // do not process request on the dispatcher thread, schedule it on ThreadPool // otherwise you will prevent other incoming requests from being dispatched ThreadPool.QueueUserWorkItem( ctx => { var response = (HttpListenerResponse)ctx; using (var str

Categories : C#

Writing JSON to a stream without buffering the string in memory
Turns out I needed to Google for a bit longer. JSON.NET does indeed support this via its JsonWriter class. My example would be written: Stream stream = ...; using (var streamWriter = new StreamWriter(stream)) using (var writer = new JsonTextWriter(streamWriter)) { writer.Formatting = Formatting.Indented; writer.WriteStartArray(); { writer.WriteStartObject(); { writer.WritePropertyName("foo"); writer.WriteValue(1); writer.WritePropertyName("bar"); writer.WriteValue(2.3); } writer.WriteEndObject(); } writer.WriteEndArray(); }

Categories : C#

Java: Reading XML file from a TCP stream without writing it to disk
Is that possible? If so, how could it be done? Read the data from the socket instead of reading from a File. XMLDecoder takes an InputStream which can be the socket.getInputSteam();

Categories : Java

Can ANTLR4 java parser handle very large files or can it stream files
You could do it like this: InputStream is = new FileInputStream(inputFile);//input file is the path to your input file ANTLRInputStream input = new ANTLRInputStream(is); GeneratedLexer lex = new GeneratedLexer(input); lex.setTokenFactory(new CommonTokenFactory(true)); TokenStream tokens = new UnbufferedTokenStream<CommonToken>(lex); GeneratedParser parser = new GeneratedParser(tokens); parser.setBuildParseTree(false);//!! parser.top_level_rule(); And if the file is quite big, forget about listener or visitor - I would be creating object directly in the grammar. Just put them all in some structure (i.e. HashMap, Vector...) and retrieve as needed. This way creating the parse tree (and this is what really takes a lot of memory) is avoided.

Categories : Java

IE is not showing any changes made using Backbone.js until I deleted the temp files and cookies
you would need to set cache control headers specifically for IE.. Otherwise it keeps caching all the requests and the script files.. Try setting this in youe global context so that IE does not cache the requests. // Disallow AJAX caching $.ajaxSetup({ cache: false });

Categories : Internet Explorer

WSO2 ESB XSLT Mediator creates temp files (never cleaned)
Seems temp files do not get cleaned up by the HouseKeeping Task. To clean them using the housekeeping task you can configure it in the Carbon.xml as shown below. <WorkDirectory>${carbon.home}/tmp/work</WorkDirectory> <HouseKeeping> <AutoStart>true</AutoStart> <Interval>10</Interval> <MaxTempFileLifetime>30</MaxTempFileLifetime> </HouseKeeping>

Categories : Xslt

Android: Writing XML file creates 2 files if whitespace is present in file name
Found my problem ! I actually had two calls to create new files: if (!f.exists()) f.createNewFile(); and Result result = new StreamResult(f); transformer.transform(source, result); Without whitespace in the file name, everything went well as they both treated the same files. However, with whitespace, StreamResult encodes the file name as a URL (therefore with %20 replacing spaces) whereas createNewFile() does not. The fix was simple. I removed the f.createNewFile(); line and added: result.setSystemId(java.net.URLDecoder.decode(result.getSystemId(), "UTF-8")); therefore writing the filename correctly with spaces.

Categories : Android

In python, is "args = [temp[n] for n in array(index)]" doing a check of temp[n]?
This: args = [this.scrath[c] for c in this.connections(n)] Is equivalent to this: args = [] for c in this.connections(n): args.append(this.scrath[c])

Categories : Java



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