stream 2 « API « Java I/O Q&A





1. Streaming to a new web page    coderanch.com

Here's the deal. I need to stream my PDF to a new web page. I'm not sure where to set my target. Can anyone help?? here's my code for the dispatching of the page. public void dispatchPDF(String path, HttpServletResponse newResponse) { try { newResponse.setContentType("application/pdf"); File f = new File(path); FileInputStream is = new FileInputStream(f); OutputStream os = newResponse.getOutputStream(); int b; while ...

2. byte or character stream?    coderanch.com

For monitoring progress, either one will do, since exact values rarely matter here anyway - if 40% of the bytes in a file have been downloaded, then very close to 40% of the characters have been read. (Depending on character encoding used, each character may take one to three bytes to encode. But whatever the ratio, it's generally about the same ...

3. IO Streams    coderanch.com

4. New to stream - Help!!    coderanch.com

Hello All, I am new to I/O Steam of Java.I have started stream & what i understand about steam is that, A/C to dictionary...."Stream is a river or flow of river" When i relate this meaning with Java,i understand that.... Steams in Java is just like an abstract pipe via which data or sequence data flows from Java programe to some ...

5. I/O and Streams    coderanch.com

6. IO stream password    coderanch.com

7. Filter Streams    coderanch.com

The basic idea of a data filter is that it takes in some type (like bytes) and transforms them to some other type (like characters) (Input Stream Filter) and vice-versa (Output Stream Filter). In other words, the idea behind an InputStream filter is to provide a way to modify the data from an InputStream and pass it to another class by ...

8. How do I use streams for loggin?    coderanch.com

I have two remote applications communicating through port 9091. I want to write Logging mechanism that will allow me to log all the data exchange between these applications without disturbing them. It is required that I do not change any of the existing code for the applications to allow logging. I was wondering if I could use a PushBackreader. Any ideas ...





11. stream    coderanch.com

hi i wrote a small application having 4 buttons textfield textarea like a small javaIDE using Runtime class and Process class i started to run jav applications through my editor everything is fine except , iam unable to solve the problem when i execute a program which takes input (System.in)through my application its getting struck now i want display the input ...

12. End of stream.    coderanch.com

I am writing a string using DataOutStream classes writeBytes method. os.writeBytes(m_send_buffer); On the other side I am reading using InputStream in while loop. I am using following code on the other side(proxy server) while((bytes_read=from_client.read(buffer))!=-1) { to_server.write(buffer, 0, bytes_read); to_server.flush(); } I am gettinng blocked in the loop,I guess the reason is I am not getting end of stream.Can anyone suggest an ...

13. End of stream.    coderanch.com

14. help for transfering of IO Stream    coderanch.com

15. whar is low and high leve streams    coderanch.com

Low-level streams read directly from the input medium or write directly to the output medium. Eg. a FileInputStream reads raw bytes from a file. High-level streams are streams that read from or write to other streams. Eg. a BufferedInputStream may be used to read chunks of bytes from a FileInputStream. The constructor of high-level streams always takes an other stream as ...

16. more about streams,readers, and writers    coderanch.com





17. Efficient Streaming Methods    coderanch.com

I'm looking for serveral ways to efficently stream files to my browser where I set the mime type. (*Not byte by byte but larger chunks) I want to stream PDF files as well as other files effienctly and haven't found a method that will work for me yet. Currently I'm doing it byte by byte and it takes a minute or ...

18. Files and Streams    coderanch.com

19. i/o streams and charsets...help    coderanch.com

Hello, I was wondering if anyone could help clairify something for me. I don't really know how the character sets work so by all means let me know if my thinking is all wrong. Sorry in advance for long post. Say user 1 has a system default charset of ASCII. They write a message in a JTextArea and hit the save ...

20. i have problem in Input/Output streams    coderanch.com

i make a code for reading file of byte data which have some text some pictures also i read this by byte streams it orks properlay it readed n write it to the assigned file but when i use character stream to make this file in character format it gives me error i m sending my code also.import java.io.*; public class ...

21. Creating a nonblocking stream    coderanch.com

22. How to use piped stream classes    coderanch.com

23. Video/Audio Streams    coderanch.com

24. when end of stream is found?    coderanch.com

Ctrl-Z is the keyboard input for EOF. The user has to hit Enter to get anything into your reader. So Ctrl-Z Enter ended this program with a -1. import java.io.*; public class Test { static public void main( String[] args ) throws Exception { InputStreamReader isr=new InputStreamReader(System.in); int i; while ( true ) { i = isr.read(); System.out.println( i ); if ...

25. I/O Stream.....    coderanch.com

26. when streaming doc ciontent to browser, multiple IE File Download prompts displayed    coderanch.com

I am attempting to display document content to a browser via my JSP-based web app. Using the code below, the content is displayed but only after the user clicks OK on the Internet Explorer File Download prompt 3 times. Can someone please help? Thanks! response.setHeader("Content-Disposition", "attachment; filename=\"" + docName + "\""); response.setContentType(mimeType); BufferedInputStream bis = new BufferedInputStream(obj.getContent()); ServletOutputStream so; int index; ...

27. Difference b/w Character streams and Byte streams    coderanch.com

Hello friends, I think this is the right forum for this question. What is the difference between character and byte streams right from the low level implementation to the high level implementation. what I actually feel is there is only one difference and that is when we use the character streams the data will be read as a character (i.e 16 ...

28. Difference between character streams and byte streams    coderanch.com

Hello friends, I think this is the right forum for this question. What is the difference between character and byte streams right from the low level implementation to the high level implementation. what I actually feel is there is only one difference and that is when we use the character streams the data will be read as a character (i.e 16 ...

29. Information on Streaming    coderanch.com

Oliver, Thanks for the response. I do know how to use File Streams. Lots of great examples out there too and easy to find. I guess what I'm looking for is an diagram that can show a class to class relation between all the classes in Streaming. This way if I wish to take a binary stream and convert it to ...

30. What exactly is a stream?    coderanch.com

Is it like now we have a well(file) with water(information) and then we want some water(info) in the bucket(to some user). then we use a pipe as an intermediate to extract the water from the well. Can i call this pipe the stream? kinldy let me know what exactly it is thanks.

31. problem w/ streams    coderanch.com

hi i'm a beginner in java. I would like the program to read the name and the phone number of the user into a file using input and output streams (e.g. "Angel 123456") The info for different users will also be considered. It'll be great if anyone can help although I didn't explain it too well... but thanks anyway!!!

32. i\o streams    coderanch.com

int hours = 1 String report = "report" double time = 3.50 can someone please help me with this, having lotz of trouble!!Arghh :-)...i would like to create a file that contains the info from hours, report and time. Then I would like to output the info from this file onto the terminal screen afterwards. How would I do this?? (It ...

33. streaming in a microsoft word doc corrupts file    coderanch.com

Hello, I'm trying to stream in a doc file from a shared drive. I'm going with a fairly standard approach, I supply the path as a constructor to a file object, then chain together a fileinputstream and bufferedinputstream and write the bytes out to another file on my local drive. The stream is successful, the problem is when I open the ...

34. Single Stream For Both I/O    coderanch.com

Hello Friends, For my program I need a stream which could store binary data as wellas provides extraction of data from it i.e a stream which does both input and output. As I want to create a class which stores a users details (userid,roomid,...) and also a stream, thru which data can be written to this user from another user in ...

35. Pipe or Stream needed?    coderanch.com

Welcome to the Ranch Oliver! A stream would be adecuate if the origin and sink of information would be in different java virtual machines. A pipe is used if both the origin and sink are active object, they have its own thread of execution. The textarea does not qualify. Solution: give visibility to the two classes. That is, provide the "producer" ...

36. Sending/Receiving files over Streams continuously    coderanch.com

Hi, I'm writing a small program to transfer files back and forth between 2 computers using sockets. I am using a thread class to listen to incoming streams as well so that it can be two way. My problem is, after I send the file from the sending computer using BufferedOutputStream which is received by a BufferedInputStream at the other end, ...

37. i have solve... if you Want to send full attrbuite throw stream in net work    coderanch.com

Mostafa, if you have some particularly useful code, feel free to share it. That's what this forum is for. If you ask for us to e-mail you, you may be overwhelmed with responses, indunated with spam, worse yet, BE a spammer or other scammer, or you may change your e-mail and never get our requests. On the other hand, if you ...

38. I/O Stream Communication    coderanch.com

Hi, I have two applications. One is Java based, the other is not. Both these are installed on a UNIX box. The second application takes the data available in the Standard Input Stream (System.in). I have data in my Java Application that I need to send to the second application via System.in. This means that I am actually trying to fill-in ...

39. What to use regarding streams    coderanch.com

Hi again! I'm writing another program that sends data to another java app. I know i'm going to use streams in this one. I'm planning to send a bunch of bytes over the LAN and putting the length of the data infront. say for example 0A 00 01 02 03 04 05 06 07 08 09 So the first byte is ...

40. Voice Streaming    coderanch.com

Hello ranchers, I have a project (academic)where i stream voice on LAN.. i was wondering how to go about it.. and another problemm .. say there are 2 systems on lan and to are already in a converstion.. wht if another system wanna speak with either of those.. how to tackle those situations.. please i need java rancher experts inputs!! Thanking ...

42. Multiplexing streams?    coderanch.com

Sorry about the question, but I looked on the internet and didn't find anything suitable, and I'm not a native English speaker, although I live in London...I'm studying Java NIO and would like to know what 'To multiplex' means, referring to non-blocking features of channels. What does it mean:'...This ability permits a process to multiplex many active streams...'? Thanks for any ...

43. Stream of special Charset?..    coderanch.com

Hello javaranchers, In my simpleserver, i use printwriter class to transmit characters on clients.my problem is: I wanna use color.My clients uses telnet.How can i send them stream's of data (words) that will hava a specific color? For example pascal (old-scool is here ) over 6th version, gives you the chance to print a stream (or a string whatever) on command ...

44. tool to detect unclosed streams    coderanch.com

45. consuming/finishing a stream    coderanch.com

I'm going by the recommendations here: http://jakarta.apache.org/commons/httpclient/3.0/performance.html I'm using the Apache Commons HttpClient to load test our website, and I don't want the test program to go onto the next HTTP method until it has read all the bytes from the response to each request. Here's my code: try { hc.executeMethod(myGetMethod); reader = new InputStreamReader( myGetMethod.getResponseBodyAsStream(), myGetMethod.getResponseCharSet()); BufferedReader br = new ...

46. I/O stream to List class????? argh!!    coderanch.com

Hi was wondering if you could help me I am really stuck! I got some course work from university, basically I have to write an application which uses RMI, now I have that part of cracked, and second part is I need to save what is stored in memory, I have that part also done, see below: oos.writeObject(list); now when I ...

47. IO streams    coderanch.com

48. Stream to String and vice versa    coderanch.com

Hi, i need to do some object-serializing from/to String variables. I'm not very familiar with this stream stuff so please could someone post some code particles. I use the XMLEncoder/XMLDecoder Classes from java.beans I either have an Object and want its XML representation written to a String. Or i have the String with the XML representation and want to recreate the ...

49. Performance problems with streams?    coderanch.com

I have an applet that calls back to a servlet to pull about one megabyte of data and then render it in a Java3D application. This process takes about 40 seconds on a LAN (about 105 seconds on a 128K DSL line), yet only takes 10 seconds when the same code is used as a local application. I find it hard ...

50. Append two rtf files into one rtf document using io stream    coderanch.com

Hi, I have two .rtf files generated as part of my application. I require to append these two files and generate as one single .rtf document The normal method of appending files in java does not seem to be working. The Outputfile does not write the contents of the second file. Kindlly help me resolve the issue.

51. Byte vs Character Stream    coderanch.com

Hi, When to use Byte Stream and when to use Character Stream. Is there any performance issue one over again? These are things I knew, If someone knows more, pls feel free to add. Byte - ASCII, Read & Write as Byte(1 byte) Character - UNICODE (It support alphabets for other language too), Read & Write as Character(2 Byte)

52. Implementing Piped Streams    coderanch.com

I am playing around with a multi-threaded rule-based application. I have one thread reading data from a file doing some processing and then passing the data on to a control thread. The control thread evaluates the data against a set of rules and passes the data onto other processing threads based on the results of it's evaluation. I have been reading ...

53. [how to keep the play stream cantabile]    coderanch.com

Hi, welcome to the ranch! For you non-Music majors: cantabile Pronunciation Key (kn-tb-l) Music adv. & adj. In a smooth, lyrical, flowing style. Used chiefly as a direction. Sorry I don't know how to make your video run more smoothly. I have terrible trouble with certain MP3s though. Wonder if the answer will be the same.

54. Stream back two or more files    coderanch.com

Hi I have a servlet that accepts some parameters and then return back a xml and a file in bytes back to the user. I used the following to get the files BufferedReader xmlvalue = new BufferedReader(new InputStreamReader(is)); String input = (String) xmlvalue.readLine(); Problem is I have to stream back two files, one in byte format and another in xml format. ...

55. io streams    coderanch.com

57. Sending a stream to a process    coderanch.com

Howdy, For fun I wrote an app that launches a daemon process that just sits and listens to stdin and echoes what it gets out to stdout. The main app has the Process object after it calles Runtime.exec() to launch the new process. The Process object allows me to get it's stdin and stdout through calls to Process.getInputStream() and Process.getOutputStream(), hooray. ...

58. Using streams    coderanch.com

Hi guys : I usually write files in java by creating a byte[], and then using a bytearrayoutputstream to create the file. Im thinking this is bad because for large files (files larger than the JVM memory allocation) this would cause an error. My question is : What are the best practices for copying a file of considerable size (> than ...

59. It's all about Stream...    coderanch.com

Hi' this is really makes me feel so upset. Why every time i try to execute WindowsExec file. There's no error in code but the output not correctly. WindowsExec.java : public class WindowsExec { response std_out,std_err; DataOutputStream doStream; outputer std_in; public WindowsExec() { try { String[] cmd = new String[]{"cmd.exe","/C","java","maintest"}; Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(cmd); std_out = new ...

60. Difference between Streams and Writers    coderanch.com

Jim, Ernest & Stan, Like when supermodels think really, really hard ... I am going to try to KISS this. I stripped out about 300+ lines from class Alice this morning, during one cup of coffee no less, to make ...

61. Streaming MPEG4    coderanch.com

Hello, I need to write or locate a Java process that receives streaming MPEG 4. I need to receive the MPEG4 and save it off as it comes as well as multicast it to several destinations. Should I write this myself? The data will either be arriving straight UDP or RTP. Thanks.

62. IO streams    coderanch.com

63. How to keep a stream open for multiple classes to access    coderanch.com

Hey all, I hope I'm posting this to the right forum, please forgive me if I'm not. Here's my issue: I'm a Java noob (also to programming in general) and trying to learn the language by creating my own text-based Gladiator game. It takes user input for levelups, types of strikes, weapon switches, character name, etc. I'm using an InputStreamReader piped ...

64. subclasses throw null exception when using objectoutput stream    coderanch.com

subclasses throw null exception when using objectoutput stream (I/O and Streams forum at JavaRanch) A friendly place for programming greenhorns! Register / Login Java Forums Java I/O and Streams subclasses throw null exception when using objectoutput stream Post by: Chad Schultz, Greenhorn on Mar 25, 2007 13:23:00 Here's the problem that's had me banging my head against the wall ...

65. Checked streams    coderanch.com

Hello, I'm trying to create a checksum in an applet and send it to the servlet where it can be compared. I'm having this code: //mail is a MimeMessage object: a mail containing a bit of text and an attachment and a signature URLConnection connection = getConnectionToServlet(); OutputStream emptyOutput = new OutputStream(){ public void write(int b) throws IOException { } }; ...

66. Regarding streams    coderanch.com

HI everyone, Inorder to read data from text file i used FileinputStream,and put the data into another text file by using FileOutputStream My program is compiled fine..and during the running process it is throwing an Exception of java.io.FileNotFoundException:file1(the system can'nt find the file specified)...i dont know the reason...why it is coming like this???can anyone help?? My code is: import java.io.*; public ...

67. I/O Streams and Readers    coderanch.com

Dear friends, Is it better to use BufferedInputStream or BufferedReader while reading a file? There will be a lot of data in the file, like, size will be more than 1 MB. And which is better to write the data:BufferedOutputStream or BufferedWriter? Which input and output classes will have better performance? Kindly provide your help Regards, Vijay

68. IO streams    coderanch.com

Streams are like rivers ... you can't really ask them to back up. The IO chapter in Eckell's Thinking In Java (free online) breaks down the confusing hierarchy of IO classes pretty well. BTW: The languages I used could SEEK and READ BACKWARDS on magnetic tape. It used to be great fun to watch a bank of 8 tape drives do ...

69. Tutorial on Streams and Readers    coderanch.com

70. Re-Reading from the stream...    coderanch.com

Hi all, Streams are behaving funny!!! i'll try to give you a gist of the problem instead of just blindly copy pasting the code... I have, BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); DataInputStream in_raw = new DataInputStream(socket.getInputStream()); Somewhere in the code, in a while ( true ) loop i do this:- while ( true ) { String line = in.readLine(); if ...

71. Display the stream by IE ?    coderanch.com

Hello everybody, I need your help. I have a question now. The goal is to mock a request by client, and i choose apache's HttpClient. The mock is successful, but the question is that I cant display the response's stream by IE. The request's method is post and the parameter is necessary. As i know Java can only open the IE ...

72. What's the signal of completed sending and receiving the streams?    coderanch.com

I'm implementing the application which needs to detect the completion of streams in back and forth. I need suggestion on how to iterate checking them. My program needs to wait for the received OutputStream to complete before write out and also needs to know that the InputStream is ready to be sent out there. The OutputStream is from the remote server ...

73. Establishing two-way buffered streams    coderanch.com

I am trying to establish server-client streams to communicate information to & from, with buffered streams. The problem is I can communicate from server to client just fine, but I can't get it to work the other way around. Here is the code for the server: public class SimpleServer { public static void main(String[] args) { ServerSocket serverSock = null; try ...

74. cloasing stream    coderanch.com

75. STREAMS QUERIES    coderanch.com

76. Binding a input character stream to an HTML page transmitted over HTTP    coderanch.com

Basically I want to find a way to create an input character stream from the HTML kicked back from an HTTP request. So I can select a URL, the code would then be able to grab the HTML and turn it to an input stream. I'm not looking for anything to parse it--thats all done by me programmatically. I just need ...

77. Streaming Audo File, need to Stream only 30 seconds    coderanch.com

Hi all, Not sure whether this is the correct Forum to post this Question. Anyway, this is my problem. I am streaming a Audio File from a URL and setting the HttpServletResponce with the streamed data as shown in the code below. My problem is, now I have to stream only the first 30 seconds of the audio file, and not ...

79. Streaming    coderanch.com

Hi, I would like to play a RTSP streaming from Darwin using JMF or other API, but I tried many ways without success. I have been looking through many threads and I couldn't find any solution for that problem. Does anybody have an example or a reference to help me on that? *Darwin is working ok. Thanks, Pedpano.

80. Swimming up Stream    coderanch.com

The book may have been clarifying that the variable (more correctly, "object reference") is of type X and so is the object since it is possible that they are different. Here is an example where they are not the same: Object o = "hello"; The reference is of type java.lang.Object. The object is of type java.lang.String. And another: InputStream in = ...

81. Progress Bar while using Streaming    coderanch.com

A friendly place for programming greenhorns! Register / Login Java Forums Java Java in General Progress Bar while using Streaming Post by: Rebecca Witmer, Ranch Hand on Feb 21, 2005 14:46:00 I have already created an application that will play a long audio file using SourceDataLine. Now I am looking for a way to do three things: 1) Display ...

82. Large Bit Stream    coderanch.com

83. Can I change the current position in Stream??    coderanch.com

Hi, I am using BufferReader for reading a file and this Reader supports skip().But skip() needs the number of characters needs to be skipped.How I can get that? My situation is: I am reading a file line by line and not writting it anywhere and checking condition and if condition not match I should skip next line. Can you please guide ...

84. What is the diff. between character-stream and byte stream which one is better?why?    coderanch.com

Hi, Some differences are there. Byte Stream : Bytes stream reads or writes the data as byte( reads as combination 0s and 1s ) from the underlying stream. Such a underlying streams are Socket or file. Character Stream : It reads or writes the data as character. But interanally it reads the bytes and converting into a character. Bytes Stream: ============ ...

85. What is "err" stream ?    coderanch.com

I'm not sure what you mean by "normal IOStream". The "err" stream is an OutputStream. It differs from the "out" stream in that it prints its output to "standard error" (or stderr) where as "out" prints to "standard out" (or stdout). The terms stderr and stdout steam from Unix where it is common to separate the "regular" output from the error ...

86. File input ouput streams    coderanch.com

Please look at the code snippet below public void methodA(){ BufferedInputStream fin = null; try { fin =new BufferedInputStream(new FileInputStream(fileName)); load(fin); } catch (Exception expt) { System.out.println("File Not Found"); } finally { try { fin.close(); } catch (Exception expta) { System.out.println("Unable to close"); } } } public void load(InputStream inStream) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(inStream)); while(true){ //code ...

87. File to stream on request !    coderanch.com

88. Stream CorruptedException invalid type code AC    coderanch.com

Usual approach to an Exception:- You will have to look at the API, find the name of the Exception at the bottom left, and read about it. It doesn't really tell you a lot, I am afraid. Go to the line where the JVM thinks the problem occurred. You can tell where it is; it is in the getUserList method, line ...

89. Stream Tokeniser    coderanch.com

Not enough info concerning the text file you are trying to parse... However, if "$"'s are the only things seperating the data, ie. the data looks like $6,234.56$2,200.00$200.00, then use the "$"'s as delimeters. Ex. // s is a String containing the data from the text file StringTokenizer st = new StringTokenizer( s, "$" ); while (st.hasMoreTokens()) { System.out.println(st.nextToken()); } You ...

90. how to devide the stream?    coderanch.com

91. Byte stream    coderanch.com

92. how to set the error stream using "java" option -D    coderanch.com

Hi, i'm trying to use the System.err.println("...."); in my program in a catch block, but how do i specify the error stream in the java command when i invoke my program. by default, if i don't mention anything, i suppose the error stream is the same as the output stream. But i want to log into a file.. like an error ...

93. inherited stream    coderanch.com

Hi every one, I have creating a writing file then two reading file to read two differnt thing from writing file in superclass .but now I have problem in adding a method in a each subclass to specity the type object being created from reading file all I know that this method have a parametr type String (fileName) and it must ...

94. Problem related to java Byte Stream.    coderanch.com

while( in.read() != -1) { System.out.println(in.read()); out.write(in.read()); } Actually if you see the code above, you call read() few times, in the while loop, in the System.out.println(), and in the out.write(). The first time you call in.read() (in the while loop), you never store the byte that you've read into the out. The same thing when you call System.out.println(), you also ...

95. Help with file streams    coderanch.com

I seem to be able to load the files in my program. Then I can loop through the lines one time, but if I try a second loop to load the strings into an array that one won't work. Here's my code. I thank you for any help in advance. Its the 4th while loop that isn't working. The first three ...

97. I/O Files and streams    coderanch.com

I need help with this program also. I have looked high and low an can't fine any example to help me on this one either. our instructor is no help at all. this is my last class before a get my degree and I have just about decided to drop out. Please help me. also if you know where I can ...

98. Java media streaming    coderanch.com

Hi guys. Wondering if you could help me out with a couple of tips. I need to look at writing a video streaming app in Java, that takes video clips from a DB. Just wondering if anyone could pint me in the right direction; do I need to use JavaFX or can I use regular Java? Any sample code or good ...

99. Facing problem in IO stream operation    coderanch.com

100. Difference between Reader/Writer and InputStream/Output Stream?    coderanch.com

Hi, The Reader/Writer class hierarchy is character-oriented, and the Input Stream/Output Stream class hierarchy is byte-oriented. Basically there are two types of streams.Byte streams that are used to handle stream of bytes and character streams for handling streams of characters.In byte streams input/output streams are the abstract classes at the top of hierarchy,while writer/reader are abstract classes at the top of ...