w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Read Multiple files from Single Stream
use your own XML tags to delimit the files: <file name="directoryA/folderB/filename"> </file> and put the XML for the file itself inside those tags. Make the tag name more elaborate if you're worried about "file" being used within the XML.

Categories : Java

PHP Read/Write files on remote server
Did you set the enable-url-fopen-wrapper in your php.ini?(only if your php version is older) Please look @ php remote files storing in example 2

Categories : PHP

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

Multiply read text files files don't seem to exist?
Just a "random guess", maybe to error message is just misleading? Remember there is a limit on the number of opened files -- or to be precise of the number of file descriptors. Given the high number of process involved, it is quite possible that at some point during execution that limit is reached...

Categories : Python

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

How to chain write stream, immediately with a read stream in Node.js 0.10?
request(url).pipe(fs.createWriteStream(filename)).pipe(writestream); is the same as this: var fileStream = fs.createWriteStream(filename); request(url).pipe(fileStream); fileStream.pipe(writestream); So the issue is that you are attempting to .pipe one WriteStream into another WriteStream.

Categories : Node Js

Balancing slow I/O in a fast stream read stream
I just ran into this problem last night, and in my hackathon induced sleep deprived state, here is how I solved it: I would increment a counter whenever I sent a job out to be processed, and decremented the counter when the operation completed. To keep the outbound traffic from overwhelming the other service, I would pause the stream when there was a certain number of pending outbound requests. The code is very similar to the following. var instream = fs.createReadStream('./combined.csv'); var outstream = new stream; var inProcess = 0; var paused = false; var rl = readline.createInterface(instream, outstream); rl.on('line', function(line) { inProcess++; if(inProcess > 100) { console.log('pausing input to clear queue'); rl.pause(); paused = true; }

Categories : Node Js

How to read text files without defining the location?
"./" is to specify current directory. if you use File f1 = new File("./"); then f1 is reference of current directory. if your application is at C:UsersDesktopapplication.exe place then all files & folder at C:UsersDesktop can access by "./" string

Categories : Java

How to read existing text files without defining path
You could use Directory.GetCurrentDirectory: var path = Path.Combine(Directory.GetCurrentDirectory(), "\fileName.txt"); Which will look for the file fileName.txt in the current directory of the application.

Categories : C#

Read a text from string then compare on list of xml files using c#
Maybe you should read first just the txt files and get the list of valid xml files (so not create the xmllist at the beginning with the GetFiles), then separately open them. So you will not have the a O2 complexity (two nested foreach).

Categories : C#

Read filenames from a text file and then make those files?
try : echo -e "$correctFilePathAndName" | touch EDIT : Sorry correct piping is : echo -e "$correctFilePathAndName" | xargs touch The '<' redirects via stdin whereas touch needs the filename as an argument. xargs transforms stdin in an argument for touch.

Categories : Linux

Python Read Large Text Files Probelm
Python's zip function returns a list of tuples. So if fetches the complete files to build this list. Use itertools.izip instead. It will return an iterator of tuples. with open(in_file1,"r") as f1, open(in_file2,"r") as f2: for (line1, line2) in izip(f1, f2): compare(line1, line2)

Categories : Python

Can't Read Encoded Text in Visual FoxPro DBF FIles
I would expect if it is FoxPro database, that the Russian there is encoded in some pre-Unicode encoding for Russian as for most Eastern European languages in ancient times. For example: Windows-1251 or ISO 8859-5.

Categories : Python

Using Stream.Read() vs BinaryReader.Read() to process binary streams
Your codes could be much more identical. I was wrong about that. ReadByte() actually returns byte. No, there is no principal difference between the two approaches. The extra Reader adds some buffering so you shouldn't mix them. But don't expect any significant performance differences, it's all dominated by the actual I/O. So, use a stream when you have (only) byte[] to move. As is common in a lot of streaming scenarios. use BinaryWriter and BinaryReader when you have any other basic type (including simple byte) of data to process. Their main purpose is conversion of the built-in framework types to byte[].

Categories : C#

How can I always capture the entire content of a network stream read in a single operation of an asynchronous read callback function?
You can't rely on any stream to return amount of data you've asked in Read request. This is especially true for remote streams (raw network, HTTP, remote file systems). Easy solution is to wrap stream with StreamReader that will take care of properly handling partial reads from stream as well encoding. Alternative solution - wrap another custom stream over network stream to read and buffer all data first (note that "all" in case of network stream may be hard to define).

Categories : C#

FPDF error: Unexpected end of stream
After hours and days or researching, I found that a png image I was trying to use was not uploaded successfully....it was partially uploaded....I minified the image and reuploaded, and the error disappeared.

Categories : PHP

Is there a generator that will turn a stream of text into a stream of lines?
After reading your edit, maybe you could modify the stream object which returns arbitrary amounts of text? For example, in the stream.next() method, there is some way the stream generates a string and yields it when .next() is called. Could you do something like: def next(self): if ' ' in self.remaining: terms = self.remaining.split(' ') to_yield, self.remaining = terms[0], ''.join(terms[1:]) yield to_yield else: to_yield = self.remaining + self.generate_arbitrary_string() while ' ' not in to_yield: to_yield += self.generate_arbitrary_string() to_yield, self.remaining = terms[0], ''.join(terms[1:]) yield to_yield This pseudocode assumes that the stream object generates some arbitrary string with generate

Categories : Python

can't read multipe text files through a loop in ruby on rails
Try to change this line @params = data[1] to @params << data[1] Or better refactor the code a bit, something like def index @params = [] Dir.glob("/home/sbrc/sukanta/opengrok/*.txt") do |file| data = IO.readlines(file) @params << [data[1], data[4]].join('@') if data[0] == "JBP PROD " end end

Categories : Ruby On Rails

read multiple text files and count the occurances of a word?
The simplest way would be to create a map of strings to ints. std::map<std::string, int> And then increment the containing int, or add to the map if it doesn't exist. http://www.cplusplus.com/reference/map/map/ If you're using c++11(I think) or later, you can even use unordered_map, which instead of using sorting to access elements uses hashing. This is an optimization you could look into, if performance matters. Here's some sample code to get you started #include <iostream> #include <map> #include <string> using namespace std; void incrementString(map<string, int> &theMap, string &theString) { if(theMap.count(theString)) { theMap[theString]++; } else { theMap[theString] = 1;//This fixes the issue the other poster menti

Categories : C++

Efficient way to read text files having irregular formats without using FOR loop in R
For the first File you can use do the following: Parse the date you read only 2 lines using readLines dd <- readLines( textConnection('internal 1.0 (free) -1 Sep 1990'),n=2) regmatches(dd,gregexpr('[A-Z][a-z]{2} [0-9]{4}$',dd))[[1]] "Sep 1990" ## strsplit(...,' ') if you want month/and year separately Then you read the matrix using something like : read.table(...,skip=2) For the second File , you can use `strsplit to read the parameters in the file first 6 lines: dd <- readLines(textConnection('ncols 256 nrows 172 xllcorner 730000 yllcorner 227000 cellsize 1320 NODATA_value -9999 '),n=6) matrix(unlist(strsplit(dd,' +')),ncol=2,byrow=TRUE) [,1] [,2] [1,] "ncols" "256" [2,] "nrows" "172"

Categories : R

Network stream stuck on stream.Read(byte[] byte, int offset, int size)
Because it's a stream, and can be partial received. Are you sure you are always receiving packages with te size of 2048 bytes? int i = 0; int bytesNeeded = 200; int bytesReceived = 0; do { //read byte from client int bytesRead = stream.Read(receivedBytesRaw, bytesReceived, bytesNeeded-bytesReceived); bytesReceived += bytesRead; // merge byte array to another byte array } while (bytesReceived < bytesNeeded); I think you need a frame protocol, try create a protocol like, writing the size of the data that follows. example: (psuedo) void SendData(byte[] data) { // get the 4 bytes of a int value. byte[] dataLength = BitConverter.GetBytes(data.Lenght); // write the length to the stream. stream.Write(dataLengt

Categories : C#

troubleshooting JAXBUnmarshalException: Unexpected end of stream (RESTeasy)
Your JSON is incorrect. The method accepts List, so you must send an array of Toy Objects: [{"toyName":"buzzlightyear", "toyMaker":"mattel"}] (note the braces). For more objects: [{"toyName":"buzzlightyear", "toyMaker":"mattel"},{"toyName":"rex", "toyMaker":"mattel"}]

Categories : Json

Can I migrate remote SVN to local disk without exporting dmp files on remote server?
You can dump only latest revision range with the -r switch. svnadmin dump REPOS_PATH [-r LOWER[:UPPER]] [--incremental] [--deltas] and then you can load this increment in the new repository. Reference: http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.dump.html Example: http://www.vioan.ro/wp/2007/07/31/dumprestore-for-subversion-repository/

Categories : Svn

"unexpected end of stream" thrown during NetHttpRequest.execute() when uploading file
OK, I figured this out. After more debugging I was able to eliminate a lot of variables and convinced myself this bug had to exist in the core HTTP library. Some googling found some people referencing bugs in Android's implementation of HTTP keep alive (https://code.google.com/p/googleappengine/issues/detail?id=9291, Weird EOFException on Galaxy Nexus, etc.). So I added this code to my activity: System.setProperty("http.keepAlive", "false"); And that fixed my problem. Annoying workaround, but it works.

Categories : Android

Getting stream posts by fql query with limit returns unexpected results
For some odd reason, when you specify a subquery (be it a useful or useless one), the desired results are more likely to show up. Example: SELECT post_id,like_info.like_count FROM stream WHERE post_id IN (SELECT post_id FROM stream WHERE source_id = page_id_here) limit 5 Hope this will help!

Categories : Javascript

read multiple xml files from the folder and write one output text file(comma separated)
Use this to iterate all files in your directory: Read all files in a folder Output (file in dir) use as input here Document doc = builder.parse("<dir file>"); If file is not xml, it either return null or exceprion is raised (I dont know currently). Eitherway, you will have to solve this.

Categories : Java

Python QT QNetworkRequest exits with "(process:3265): GLib-ERROR **: Creating pipes for GWakeup: Too many open files"
Is your condition self.image_reply.error() == Qt.QNetworkReply.NoError always true? If it ts false, deleteLater will not be called. Try to set 'Connection: close' header: image_request.setRawHeader("Connection", "close"); Also try to call self.image_reply.close() manually.

Categories : Python

A view for text files in android like ImageView for Images in android
Use like this: if(filetype.toString().equals(".pdf")) { //place your pdf image imageview= (ImageView)findViewById(R.id.imageView); Drawable res = getResources().getDrawable(imageResource); imageView.setImageDrawable(res); } else if(filetype.toString().equals(".docs")) { //place your docs image imageview= (ImageView)findViewById(R.id.imageView); Drawable res = getResources().getDrawable(imageResource); imageView.setImageDrawable(res); }

Categories : Android

How to save , read and write files in android in external storage?
Please read the Android documentation regarding External Storage. Pay attention to the getExternalFilesDir(). You can retrieve the path to the external storage using this method. When you have the path, you can use the File object to create the data folder on the external storage like this: File dataDirectory = new File(getExternalFilesDir() + "/data/"); Then create the folder by applying the mkdirs()-method on the File object: dataDirectory.mkdirs(); To write to external storage, you will indeed have to declare this in the manifest: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

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

"The remote server returned an unexpected response: (400) Bad Request"
I notice that you've increased the maxRequestLength for your client, but not your server: <system.web> <!-- ... --> <httpRuntime executionTimeout="180" maxRequestLength="2147483647" /> </system.web> This configuration option is really only relevant for the server, since it sets the allowed size of inbound requests. In any case, I would add this part to your server configuration file and see if that takes care of the problem. The default request size is 4MB, and I know from experience this can cause the error you're reporting.

Categories : C#

remote procedure call (RPC) protocol stream is incorrect
What is the code you are trying to test? Are you using a testing database ? What is the error you are getting ? Is this an exception or just a Test Failed ? We need more info to help you !

Categories : C#

Generating and downloading a CSV - stream does not support seeking (not remote)
From my experience, rewind() doesn't work with php://output, but it does with php://memory. If your plan is to grab de output to make a force download later, then you don't need to rewind the stream; reading it with stream_get_contents() will be enough You final code should be $fp = fopen('php://output', 'w'); foreach ($list as $fields) { fputcsv($fp, $fields); } $output = stream_get_contents($fp); fclose($fp);

Categories : PHP

Android read text file from internet
Did you added internet permission to your Manifest file? Are you launching your code in separate thread (please don't catch NetworkOnMainThreadException) Check LogCat what exception do you have? Removed c.setDoOutput(true); this is used to send data to server. Here how it should be: new Thread() { @Override public void run() { String path ="http://host.com/info.txt"; URL u = null; try { u = new URL(path); HttpURLConnection c = (HttpURLConnection) u.openConnection(); c.setRequestMethod("GET"); c.connect(); InputStream in = c.getInputStream(); final ByteArrayOutputStream bo = new ByteArrayOutputStre

Categories : Android

how to read text file from internet in Android
A couple things: 1) You cannot modify the UI thread from a background Thread. doInBackground() runs on a background Thread, you should update your UI on onPostExecute(). 2) You have two implementations of doInBackground(). The first one doesn't override the doInBackground() in AsyncTask. Move this code to the one that overrides AsyncTask 3) doInBackground() should return a String so you can use it to update the text on your TextView in onPostExecute. AsyncTask should look like this AsyncTask<String,Void,String> 4) When you create the DonwloadFile() instance you should invoke its execute(), otherwise the background Thread will not start and doInBackground() will not get called. 5) Your while loop is only checking if there is still data on the InputStream, but it is not storing it

Categories : Android

Android and Facebook SDK - Is RequestAsyncTask still working after my application exits?
It's running on a separate thread, so it should continue to run unless the user kills the application process. One way to get around that is to use a Service to run the thread. That way if the user kills the application process, the thread isn't tied to it. You can show the progress in the notifications. This is a pretty standard convention for uploading/downloading files.

Categories : Android

Is it ok if a worker thread that pulls from a BlockingQueue never exits in android?
As the taskQueue is a blocking queue, no. Leaving this thread running throughout the application's life will not cause any noticeable effect. If TaskQueue wasn't a blocking then it would. Your application will consume a near a whole core of processing power looping as fast as it can. A blocking queue will cause a thread invoking method 'take' to halt until there is some result available to return. A non-blocking queue will return null or throw an exception.

Categories : Java

jquery validation ajax and remote field unexpected behavior
You don't need the onsubmit: true option because that's the default behavior. Important: as per docs, onsubmitValidate the form on submit. Set to false to use only other events for validation. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value. In other words, you must remove that line because true will break the plugin. Quote OP: "When I enter a UserName that already exists I get the 'User Name already exists' message and the submitHandler is not called, as expected. But if any other validation check fails, the form gets posted normally to the form action url, and the submitHandler callback never seems to get called." The form is not supposed to post if there are outstanding errors, and the submitHandler is not

Categories : Jquery

how to get remote java class file byte stream at runtime?
Get the file from the remote server, modify it locally and push it back to the remote server. Getting the file from the remote server can be using FTP, HTTP or may be write a small socket server running on the reomte machine and a client on your machine. About how will the class be reloaded in the JVM(since you said its already loaded), I have no idea :)

Categories : Java

Read Text from website and put it in a string (Android , Eclipse)
Use equals instead of ==. if(total.toString().equals("Text")) == checks if two references point to the same object, which won't be true in that case.

Categories : Android



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