outputstream

Issue with objective C outputstream flushing?

北城以北 提交于 2019-12-10 11:43:43
问题 Hello I'm having an issue with an NSOutputStream in Objective C. I've got a server running up on my computer and the iPhone emulator sends data to the server and the server should send it back. The only issue is, when I send it, It's not sending the text until I exit out of the Emulator, and only then does the server get the information. NSString* toSend = chatField.text; NSData* sendData = [[NSData alloc] initWithData:[toSend dataUsingEncoding:NSASCIIStringEncoding]]; [outStream write:

Cannot invoke initializer for type UnsafePointer<_> with an argument list of type (UnsafeMutableRawPointer)

守給你的承諾、 提交于 2019-12-10 11:17:37
问题 When I write the output stream in multipeer connectivity from audio buffer data I got the error Cannot invoke initializer for type UnsafePointer<_> with an argument list of type (UnsafeMutableRawPointer) I found the many solutions, but this solution not helpful for me. My code is: func send(_ buffer: AudioBuffer) { print(buffer.mData!) print(buffer.mDataByteSize) outputStreme?.write(UnsafePointer(buffer.mData), maxLength: buffer.mDataByteSize) } Thanks in advance..:) 回答1: Please check the

How do I check if output stream of a socket is closed?

拈花ヽ惹草 提交于 2019-12-10 10:16:47
问题 I have this code: public void post(String message) { output.close(); final String mess = message; (new Thread() { public void run() { while (true) { try { output.println(mess); System.out.println("The following message was successfully sent:"); System.out.println(mess); break; } catch (NullPointerException e) { try {Thread.sleep(1000);} catch (InterruptedException ie) {} } } } }).start(); } As you can see I close the socket in the very beginning of the code and then try to use it to send some

How do I redirect log4j output to my HttpServletResponse output stream?

梦想的初衷 提交于 2019-12-09 17:46:40
问题 I'm using log4j 1.2.15 in a Spring 3.1.1.RELEASE application deployed on JBoss AS 7.1.1.Final. I'm trying to route output written in log4j to my response output stream. I have output written like this private static final Logger LOG = Logger.getLogger(TrainingSessionServiceImpl.class); … LOG.info("Creating/updating training session associated with order #:" + order.getId()); and I'm trying to route it to my output stream like so … @RequestMapping(value = "/refreshPd", method = RequestMethod

Does swift have a protocol for writing a stream of bytes?

本秂侑毒 提交于 2019-12-09 04:23:07
问题 I can't find anything in the Swift book about io. Is there any generic protocol similar to Java's OutputStream or Go's Writer interface for writing a stream of bytes? If you are writing a class that returns a stream, do you need to write your own protocol or use an Objective C protocol? To be clear am asking for a Swift native interface for this not because I avoiding using Objective C or Cocoa, but for a description of the expected behavior for Swift to Swift code going forward. 回答1: This is

How to know whether writing to stream would result in java.io.IOException: write failed: EBADF (Bad file number)

断了今生、忘了曾经 提交于 2019-12-08 09:54:25
问题 I know there are a number of posts here on the java.io.IOException: write failed: EBADF (Bad file number) exception, but non of them seems to answer my particular question: Suppose my activity is called with Intent.ACTION_VIEW and I got a Uri via Uri uri = intent.getData() that starts with content:// from which I read some data (for example a pdf file). Now I want to find out whether I can also write to that Uri to decide whether a "save" button should be shown to the user, or just a "save as

converting outputStream to byte array [duplicate]

假装没事ソ 提交于 2019-12-08 04:55:47
问题 This question already has answers here : How to convert outputStream to a byte array? (4 answers) Closed 2 years ago . How can I get the bytes of an outputStream, or how can I convert an outputStream to a byte array? 回答1: From a theoretical perspective (i.e., irrespective of whether it makes sense in practice as a use case), this is an interesting question that essentially requires the implementation of a method like public abstract byte[] convert(OutputStream out); The Java OutputStream

Sending big file using FileInputStream/ObjectOutputStream

假如想象 提交于 2019-12-08 04:42:47
问题 I need help on my homework, any help will be much appreciated. I can send small files without a problem. But when i try to send let’s say a 1GB file byte array sends OutOfMemoryError so i need a better solution to send file from server to client. How can i improve this code and send big files, please help me. Server Code: FileInputStream fis = new FileInputStream(file); byte[] fileByte = new byte[fis.available()]; //This causes the problem. bytesRead = fis.read(fileByte); oos = new

ObjectOutputStream hanging forever

╄→尐↘猪︶ㄣ 提交于 2019-12-08 03:52:37
问题 I have a client that connects to a server using SSLSocket. Next, I try to create an OOS with ObjectOutputStream oos = new ObjectOutputStream(sslsocket.getOutputStream()); If everything is working well on the server side, this is fine. However, I would like to put something in place on my client side that tries to create the ObjectOutputStream, but if it hasn't happened in 60 seconds, log the error and continue processing. I don't see any timeout options for this. Any examples of how this

Loading and saving resources inside a runnable jar? [duplicate]

拈花ヽ惹草 提交于 2019-12-07 20:44:28
This question already has answers here : Closed 6 years ago . Possible Duplicate: How can a Java program use files inside the .jar for read and write? I am in the process of creating a game, and I want it all to run from on runnable jar file, so all of my resources (images and text files) are going to be inside the jar file. The problem that I'm having with this is that it is extremely difficult to deal with files inside the jar. I am using eclipse, which can sometimes play tricks on you because it will find the files if you run it from eclipse, but if you export it won't. I just want to know