My client is a web browser, and sending request to myserver using this url:
http://localhost
This is the server side code. The problem lies in the run method of the ServingThread class.
class ServingThread implements Runnable{
private Socket socket ;
public ServingThread(Socket socket){
this.socket = socket ;
System....
I'm trying to read a file then append some text to a certain place in the file (ie. @ offset jabjab). The problem occurs when i'm trying to write to the file at offset jabjab. what's the error?
File contents:
Mi
<?xml Version="1.0"?>
_
File f = new File("data.dat");
String brstring = null;
String entrystring = null;
try ...
I'm trying to write a client and time server for an assignment and I'm having trouble getting the server to receive the second request from the client. The first request goes through fine without a hitch. then it just stalls. I'm actually pretty lost in this whole thing and rather uncomfortable with java still, so I have no idea what I'm...
Hello again!
I am creating a project with struts and I have a problem using Jasper IReports. I want to export some info into a pdf file and I keep getting the java.lang.IllegalStateException: getOutputStream() has already been call... Exception due to openning a ServletOutputStream in my code when the page already opens a PrintWriter.
...
Writing generated PDF (ByteArrayOutputStream) in a Servlet to PrintWriter.
I am desperately looking for a way to write a generated PDF file to the response PrintWriter.
Since a Filter up the hierarchy chain has already called response.getWriter() I can't get response.getOutputStream().
I do have a ByteArrayOutputStream where I generat...
What is the difference between PrintStream and PrintWriter? They have much methods in common. I always mix up this classes because of that reason. And I think we can use them for exactly the same. But there has to be a difference. Otherwise there was only one class.
I first searched on StackOverflow, but not yet this question.
...
I have this simple application with a couple of classes which are all related. There's one, the main one, for which there is only one instance of. I need to save save and load that using a text stream.
My instructor requirement is BufferedReader to load the stream and PrintWriter to save it. But is this even possible? To persist a data ...
Hi everyone.
I have an Applet that makes a request to a Servlet. On the servlet it's using the PrintWriter to write the response back to Applet:
out.println("Field1|Field2|Field3|Field4|Field5......|Field10");
There are about 15000 records, so the out.println() gets executed about 15000 times.
Problem is that when the Applet gets t...
I have the following class, which as you will see has rather a rather redundant formatNameAndAddress method:
package hu.flux.helper;
import java.io.PrintWriter;
import javax.servlet.jsp.JspWriter;
// A holder for formatting data
public class NameAndAddress
{
public String firstName;
public String middleName;
public String lastNam...
I wanted to consolidate two functions.
After getting a viable solution, I decided to play with the code a bit further, and came up with this:
package hu.flux.helper;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.i...
I'm trying to make a basic program that allows a user to create a text file and add a list of words to it. When the user writes "stopnow" - the file should close. Unfortunately, right now it's just an infinite loop. What am I doing wrong:
import java.util.Scanner;
import java.io.*;
public class WordList
{
public static void ...
so let's say I ask the user to specify what he wants to call a new file
System.out.println("What do you want to call the file?");
String outputFile = keyboard.nextLine();
now to write the file I would do:
PrintWriter outputFile = new PrintWriter(fileName);
My question are:
I know by default it saves to the local folder. How do I...