Java Code Examples for java.io.OutputStreamWriter

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AdminCmd, under directory /src/main/java/be/Balor/Tools/Files/Unicode/.

Source file: UnicodeUtil.java

  19 
vote

/** 
 * Save a String to a file in UTF8 with Signature
 * @param file file to save
 * @param data data to write
 * @param append append data
 * @throws IOException something goes wrong with the file
 */
public static void saveUTF8File(final File file,final String data,final boolean append) throws IOException {
  BufferedWriter bw=null;
  OutputStreamWriter osw=null;
  final FileOutputStream fos=new FileOutputStream(file,append);
  try {
    if (file.length() < 1) {
      fos.write(UTF8_BOMS);
    }
    osw=new OutputStreamWriter(fos,"UTF-8");
    bw=new BufferedWriter(osw);
    if (data != null) {
      bw.write(data);
    }
  }
  finally {
    try {
      bw.close();
      fos.close();
    }
 catch (    final Exception ex) {
    }
  }
}
 

Example 2

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/builder/.

Source file: D80ReportView.java

  18 
vote

private void saveD80ToHtmlFile(String fileName) throws IOException {
  File f=new File(fileName);
  if (f.exists()) {
    f.delete();
  }
  OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream(f));
  osw.write(d_d80Report);
  osw.close();
}
 

Example 3

From project aether-core, under directory /aether-connector-file/src/main/java/org/eclipse/aether/connector/file/.

Source file: FileRepositoryWorker.java

  18 
vote

private void writeChecksum(File src,String targetPath) throws IOException, Throwable {
  Map<String,Object> crcs=ChecksumUtils.calc(src,checksumAlgos.keySet());
  for (  Entry<String,Object> crc : crcs.entrySet()) {
    String name=crc.getKey();
    Object sum=crc.getValue();
    if (sum instanceof Throwable) {
      throw (Throwable)sum;
    }
    File crcTarget=new File(targetPath + checksumAlgos.get(name));
    OutputStreamWriter crcWriter=new OutputStreamWriter(new FileOutputStream(crcTarget),"US-ASCII");
    crcWriter.write(sum.toString());
    crcWriter.close();
  }
}
 

Example 4

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/helper/.

Source file: GZIPHelper.java

  18 
vote

public byte[] zippedSession(Session session) throws IOException {
  ByteArrayOutputStream byteStream=new ByteArrayOutputStream();
  Base64OutputStream base64OutputStream=new Base64OutputStream(byteStream);
  GZIPOutputStream gzip=new GZIPOutputStream(base64OutputStream);
  OutputStreamWriter writer=new OutputStreamWriter(gzip);
  gson.toJson(session,session.getClass(),writer);
  writer.flush();
  gzip.finish();
  writer.close();
  return byteStream.toByteArray();
}
 

Example 5

From project amplafi-sworddance, under directory /src/main/java/com/sworddance/util/perf/.

Source file: LapTimerCollection.java

  18 
vote

/** 
 * Write out the stored LapTimers in Excel CVS format
 * @param fileName
 * @throws IOException
 */
public void writeCSV(String fileName) throws IOException {
  FileOutputStream f=new FileOutputStream(fileName);
  OutputStreamWriter f0=new OutputStreamWriter(f);
  try {
    this.writeCSV(f0);
  }
  finally {
    f0.close();
    f.close();
  }
}
 

Example 6

From project arquillian-container-openshift, under directory /openshift-express/src/main/java/org/jboss/arquillian/container/openshift/express/util/.

Source file: IOUtils.java

  18 
vote

/** 
 * Copy chars from a Reader to bytes on an OutputStream using the specified character encoding, and calling flush. This method buffers the input internally, so there is no need to use a BufferedReader. Character encoding names can be found at IANA. Due to the implementation of OutputStreamWriter, this method performs a flush. This method uses  {@link OutputStreamWriter}.
 * @param input the Reader to read from
 * @param output the OutputStream to write to
 * @param encoding the encoding to use, null means platform default
 * @throws NullPointerException if the input or output is null
 * @throws IOException if an I/O error occurs
 * @since Commons IO 1.1
 */
public static void copy(Reader input,OutputStream output,String encoding) throws IOException {
  if (encoding == null) {
    copy(input,output);
  }
 else {
    OutputStreamWriter out=new OutputStreamWriter(output,encoding);
    copy(input,out);
    out.flush();
  }
}
 

Example 7

From project as3-commons-jasblocks, under directory /src/main/java/org/as3commons/asblocks/impl/.

Source file: ASTASProject.java

  18 
vote

/** 
 * Writes the ActionScript code in the given CompilationUnit to the given directory, creating any subfolders for package hierarchy as appropriate, and deriving the filename from the name of the type defined by the compilation unit.
 */
private void write(String destinationDir,IASCompilationUnit cu) throws IOException {
  String filename=filenameFor(cu);
  File destFile=new File(destinationDir,filename);
  destFile.getParentFile().mkdirs();
  FileOutputStream os=new FileOutputStream(destFile);
  OutputStreamWriter out=new OutputStreamWriter(os);
  factory.newWriter().write(out,cu);
  out.close();
}
 

Example 8

From project baseunits, under directory /src/test/java/jp/xet/baseunits/tests/.

Source file: CannedResponseServer.java

  18 
vote

private void serveCannedResponse(Socket client) throws IOException {
  OutputStreamWriter writer=new OutputStreamWriter(client.getOutputStream());
  try {
    writer.write(cannedResponse);
  }
  finally {
    writer.close();
  }
}
 

Example 9

From project BazaarUtils, under directory /src/org/alexd/jsonrpc/.

Source file: JSONRPCHttpClient.java

  18 
vote

protected void cacheResult(JSONObject jsonResponse,String paramHash,Context c,int cacheTime){
  File vCache=CacheUtils.getCacheFile(paramHash + ".json",c);
  try {
    OutputStreamWriter out=new OutputStreamWriter(new FileOutputStream(vCache));
    out.write(jsonResponse.toString());
    out.close();
  }
 catch (  IOException e) {
    Log.w(TAG,"BazaarUtils :: cacheResult",e);
  }
}
 

Example 10

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/utils/.

Source file: Log.java

  18 
vote

private static BufferedWriter GetWriter(){
  try {
    OutputStreamWriter oWriter=new OutputStreamWriter(new FileOutputStream(logFile,true));
    BufferedWriter bWriter=new BufferedWriter(oWriter);
    return bWriter;
  }
 catch (  FileNotFoundException e) {
    return null;
  }
}
 

Example 11

From project candlepin, under directory /src/main/java/org/candlepin/pki/impl/.

Source file: BouncyCastlePKIUtility.java

  18 
vote

private byte[] getPemEncoded(Object obj) throws IOException {
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  OutputStreamWriter oswriter=new OutputStreamWriter(byteArrayOutputStream);
  PEMWriter writer=new PEMWriter(oswriter);
  writer.writeObject(obj);
  writer.close();
  return byteArrayOutputStream.toByteArray();
}
 

Example 12

From project capedwarf-blue, under directory /admin/src/main/java/org/jboss/capedwarf/admin/.

Source file: AdminServlet.java

  18 
vote

private void serveVelocityPage(HttpServletRequest req,HttpServletResponse resp) throws Exception {
  Context context=CapedwarfVelocityContext.createThreadLocalInstance(manager,req);
  Template template=velocity.getTemplate(getTemplatePath(req));
  OutputStreamWriter writer=new OutputStreamWriter(resp.getOutputStream());
  template.merge(context,writer);
  writer.flush();
  CapedwarfVelocityContext.clearThreadLocalInstance();
}
 

Example 13

From project cogroo4, under directory /cogroo-gc/src/main/java/org/cogroo/tools/checker/rules/util/.

Source file: RulesTreesPrinter.java

  18 
vote

/** 
 * @param args
 */
public static void main(String[] args) throws Exception {
  RulesProvider xmlProvider=new RulesProvider(RulesXmlAccess.getInstance(),false);
  RulesTreesBuilder rtb=new RulesTreesBuilder(xmlProvider);
  RulesTreesAccess rta=new RulesTreesFromScratchAccess(rtb);
  OutputStreamWriter xmlOut=new OutputStreamWriter(new FileOutputStream("target/treesXml.txt"),"UTF-8");
  RulesTrees xmlTrees=rta.getTrees();
  printRulesTrees(xmlTrees,xmlOut);
  xmlOut.close();
}
 

Example 14

From project commons-io, under directory /src/main/java/org/apache/commons/io/.

Source file: CopyUtils.java

  18 
vote

/** 
 * Serialize chars from a <code>String</code> to bytes on an <code>OutputStream</code>, and flush the <code>OutputStream</code>.
 * @param input the <code>String</code> to read from
 * @param output the <code>OutputStream</code> to write to
 * @throws IOException In case of an I/O problem
 */
public static void copy(String input,OutputStream output) throws IOException {
  StringReader in=new StringReader(input);
  OutputStreamWriter out=new OutputStreamWriter(output);
  copy(in,out);
  out.flush();
}
 

Example 15

From project cw-android, under directory /APIVersions/ReadWriteStrict/src/com/commonsware/android/rwversions/.

Source file: ReadWriteFileDemo.java

  18 
vote

public void onPause(){
  super.onPause();
  try {
    OutputStreamWriter out=new OutputStreamWriter(openFileOutput(NOTES,0));
    out.write(editor.getText().toString());
    out.close();
  }
 catch (  Throwable t) {
    Toast.makeText(this,"Exception: " + t.toString(),Toast.LENGTH_LONG).show();
  }
}
 

Example 16

From project cw-omnibus, under directory /Files/ReadWrite/src/com/commonsware/android/frw/.

Source file: EditorFragment.java

  18 
vote

private void save(String text,File target) throws IOException {
  FileOutputStream fos=new FileOutputStream(target);
  OutputStreamWriter out=new OutputStreamWriter(fos);
  out.write(text);
  out.flush();
  fos.getFD().sync();
  out.close();
}
 

Example 17

From project dawn-common, under directory /org.dawb.common.util/src/org/dawb/common/util/io/.

Source file: FileUtils.java

  18 
vote

/** 
 * @param file
 * @param text
 * @param encoding
 * @throws Exception
 */
public static void write(final File file,final String text,String encoding) throws Exception {
  BufferedWriter b=null;
  try {
    final OutputStream out=new FileOutputStream(file);
    final OutputStreamWriter writer=new OutputStreamWriter(out,encoding);
    b=new BufferedWriter(writer);
    b.write(text.toCharArray());
  }
  finally {
    if (b != null) {
      b.close();
    }
  }
}
 

Example 18

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.ui/src/main/java/com/isencia/passerelle/workbench/model/ui/utils/.

Source file: FileUtils.java

  18 
vote

/** 
 * @param file
 * @param text
 * @param encoding
 * @throws Exception
 */
public static void write(final File file,final String text,String encoding) throws Exception {
  BufferedWriter b=null;
  try {
    final OutputStream out=new FileOutputStream(file);
    final OutputStreamWriter writer=new OutputStreamWriter(out,encoding);
    b=new BufferedWriter(writer);
    b.write(text.toCharArray());
  }
  finally {
    if (b != null) {
      b.close();
    }
  }
}
 

Example 19

From project airlift, under directory /http-server/src/main/java/io/airlift/http/server/.

Source file: DelimitedRequestLog.java

  17 
vote

public DelimitedRequestLog(String filename,int retainDays,TraceTokenManager traceTokenManager,EventClient eventClient,CurrentTimeMillisProvider currentTimeMillisProvider) throws IOException {
  this.traceTokenManager=traceTokenManager;
  this.eventClient=eventClient;
  this.currentTimeMillisProvider=currentTimeMillisProvider;
  out=new RolloverFileOutputStream(filename,true,retainDays);
  writer=new OutputStreamWriter(out);
  isoFormatter=new DateTimeFormatterBuilder().append(ISODateTimeFormat.dateHourMinuteSecondFraction()).appendTimeZoneOffset("Z",true,2,2).toFormatter();
}
 

Example 20

From project AlarmApp-Android, under directory /src/org/alarmapp/web/http/.

Source file: HttpUtil.java

  17 
vote

private static String post(URL url,HashMap<String,String> data,HashMap<String,String> headers) throws WebException {
  Ensure.notNull(url);
  try {
    Ensure.notNull(url);
    HttpURLConnection http=(HttpURLConnection)url.openConnection();
    http.setRequestMethod("POST");
    http.setReadTimeout(10000);
    http.setDoOutput(true);
    http.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    setHeaders(http,headers);
    OutputStreamWriter streamToSend=new OutputStreamWriter(http.getOutputStream(),"UTF8");
    streamToSend.write(exportPostData(data));
    streamToSend.flush();
    streamToSend.close();
    return getResponse(http);
  }
 catch (  IOException e) {
    LogEx.exception(e);
    throw new WebException(NOT_CONNECTED);
  }
}
 

Example 21

From project anadix, under directory /anadix-core/src/main/java/org/anadix/impl/.

Source file: DefaultReportFormatter.java

  17 
vote

/** 
 * {@inheritDoc} 
 */
public void formatAndStore(Report report,OutputStream os){
  if (os == null) {
    throw new NullPointerException("os cannot be null");
  }
  formatAndStore(report,new OutputStreamWriter(os));
}
 

Example 22

From project andlytics, under directory /src/com/github/andlyticsproject/.

Source file: DeveloperConsole.java

  17 
vote

private String getGwtRpcResponse(String developerPostData,URL aURL) throws IOException, ProtocolException, ConnectException {
  String result;
  HttpsURLConnection connection=(HttpsURLConnection)aURL.openConnection();
  connection.setHostnameVerifier(new AllowAllHostnameVerifier());
  connection.setDoOutput(true);
  connection.setDoInput(true);
  connection.setRequestMethod("POST");
  connection.setConnectTimeout(4000);
  connection.setRequestProperty("Host","play.google.com");
  connection.setRequestProperty("User-Agent","Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13");
  connection.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  connection.setRequestProperty("Accept-Language","en-us,en;q=0.5");
  connection.setRequestProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7");
  connection.setRequestProperty("Keep-Alive","115");
  connection.setRequestProperty("Cookie",cookie);
  connection.setRequestProperty("Connection","keep-alive");
  connection.setRequestProperty("Content-Type","text/x-gwt-rpc; charset=utf-8");
  connection.setRequestProperty("X-GWT-Permutation",getGwtPermutation());
  connection.setRequestProperty("X-GWT-Module-Base","https://play.google.com/apps/publish/gwt-play/");
  connection.setRequestProperty("Referer","https://play.google.com/apps/publish/Home");
  OutputStreamWriter streamToAuthorize=new java.io.OutputStreamWriter(connection.getOutputStream());
  streamToAuthorize.write(developerPostData);
  streamToAuthorize.flush();
  streamToAuthorize.close();
  InputStream resultStream=connection.getInputStream();
  BufferedReader aReader=new java.io.BufferedReader(new java.io.InputStreamReader(resultStream));
  StringBuffer aResponse=new StringBuffer();
  String aLine=aReader.readLine();
  while (aLine != null) {
    aResponse.append(aLine + "\n");
    aLine=aReader.readLine();
  }
  resultStream.close();
  result=aResponse.toString();
  return result;
}
 

Example 23

From project android-joedayz, under directory /Proyectos/Archivos/src/net/ivanvega/Archivos/.

Source file: MainActivity.java

  17 
vote

@Override public void onClick(View arg0){
  if (arg0.equals(btnGuardar)) {
    String str=txtTexto.getText().toString();
    FileOutputStream fout=null;
    try {
      fout=openFileOutput("archivoTexto.txt",MODE_WORLD_READABLE);
      OutputStreamWriter ows=new OutputStreamWriter(fout);
      ows.write(str);
      ows.flush();
      ows.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    Toast.makeText(getBaseContext(),"El archivo se ha almacenado!!!",Toast.LENGTH_SHORT).show();
    txtTexto.setText("");
  }
  if (arg0.equals(btnAbrir)) {
    try {
      FileInputStream fin=openFileInput("archivoTexto.txt");
      InputStreamReader isr=new InputStreamReader(fin);
      char[] inputBuffer=new char[READ_BLOCK_SIZE];
      String str="";
      int charRead;
      while ((charRead=isr.read(inputBuffer)) > 0) {
        String strRead=String.copyValueOf(inputBuffer,0,charRead);
        str+=strRead;
        inputBuffer=new char[READ_BLOCK_SIZE];
      }
      txtTexto.setText(str);
      isr.close();
      Toast.makeText(getBaseContext(),"El archivo ha sido cargado",Toast.LENGTH_SHORT).show();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}
 

Example 24

From project AndroidCommon, under directory /src/com/asksven/andoid/common/contrib/.

Source file: Util.java

  17 
vote

public static boolean writeStoreFile(Context context,int uid,int execUid,String cmd,int allow){
  File storedDir=new File(context.getFilesDir().getAbsolutePath() + File.separator + "stored");
  storedDir.mkdirs();
  if (cmd == null) {
    Log.d(TAG,"App stored for logging purposes, file not required");
    return false;
  }
  String fileName=uid + "-" + execUid;
  try {
    OutputStreamWriter out=new OutputStreamWriter(new FileOutputStream(new File(storedDir.getAbsolutePath() + File.separator + fileName)));
    out.write(cmd);
    out.write('\n');
    out.write(String.valueOf(allow));
    out.write('\n');
    out.flush();
    out.close();
  }
 catch (  FileNotFoundException e) {
    Log.w(TAG,"Store file not written",e);
    return false;
  }
catch (  IOException e) {
    Log.w(TAG,"Store file not written",e);
    return false;
  }
  return true;
}
 

Example 25

From project android_external_tagsoup, under directory /src/org/ccil/cowan/tagsoup/.

Source file: XMLWriter.java

  17 
vote

/** 
 * Set a new output destination for the document.
 * @param writer The output destination, or null to usestandard output.
 * @return The current output writer.
 * @see #flush
 */
public void setOutput(Writer writer){
  if (writer == null) {
    output=new OutputStreamWriter(System.out);
  }
 else {
    output=writer;
  }
}
 

Example 26

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/util/.

Source file: Util.java

  17 
vote

public static boolean writeStoreFile(Context context,int uid,int execUid,String cmd,int allow){
  File storedDir=new File(context.getFilesDir().getAbsolutePath() + File.separator + "stored");
  storedDir.mkdirs();
  if (cmd == null) {
    Log.d(TAG,"App stored for logging purposes, file not required");
    return false;
  }
  String fileName=uid + "-" + execUid;
  try {
    OutputStreamWriter out=new OutputStreamWriter(new FileOutputStream(new File(storedDir.getAbsolutePath() + File.separator + fileName)));
    out.write(cmd);
    out.write('\n');
    out.write(String.valueOf(allow));
    out.write('\n');
    out.flush();
    out.close();
  }
 catch (  FileNotFoundException e) {
    Log.w(TAG,"Store file not written",e);
    return false;
  }
catch (  IOException e) {
    Log.w(TAG,"Store file not written",e);
    return false;
  }
  return true;
}
 

Example 27

From project androlog, under directory /androlog/src/main/java/de/akquinet/android/androlog/reporter/.

Source file: PostReporter.java

  17 
vote

/** 
 * Executes the given request as a HTTP POST action.
 * @param url the url
 * @param params the parameter
 * @return the response as a String.
 * @throws IOException if the server cannot be reached
 */
public static void post(URL url,String params) throws IOException {
  URLConnection conn=url.openConnection();
  if (conn instanceof HttpURLConnection) {
    ((HttpURLConnection)conn).setRequestMethod("POST");
    conn.setRequestProperty("Content-Type","application/json");
  }
  OutputStreamWriter writer=null;
  try {
    conn.setDoOutput(true);
    writer=new OutputStreamWriter(conn.getOutputStream(),Charset.forName("UTF-8"));
    writer.write(params);
    writer.flush();
  }
  finally {
    if (writer != null) {
      writer.close();
    }
  }
}
 

Example 28

From project archive-commons, under directory /archive-commons/src/main/java/org/archive/extract/.

Source file: WATExtractorOutput.java

  17 
vote

private void writeWARCMDRecord(OutputStream recOut,MetaData md,String targetURI,String capDateString,String recId) throws IOException {
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  OutputStreamWriter osw=new OutputStreamWriter(bos,UTF8);
  try {
    md.write(osw);
  }
 catch (  JSONException e1) {
    e1.printStackTrace();
    throw new IOException(e1);
  }
  osw.flush();
  Date capDate;
  try {
    capDate=DateUtils.getSecondsSinceEpoch(capDateString);
  }
 catch (  ParseException e) {
    e.printStackTrace();
    capDate=new Date();
  }
  recW.writeJSONMetadataRecord(recOut,bos.toByteArray(),targetURI,capDate,recId);
}
 

Example 29

From project arquillian-rusheye, under directory /rusheye-impl/src/main/java/org/jboss/rusheye/result/statistics/.

Source file: OverallStatistics.java

  17 
vote

@Override public void setProperties(Properties properties){
  Writer writer=(Writer)properties.getProperty("overall-statistics-output");
  if (writer == null) {
    writer=new OutputStreamWriter(System.out);
  }
  this.printerWriter=new PrintWriter(writer);
}
 

Example 30

From project AuthDB, under directory /src/main/java/com/craftfire/util/managers/.

Source file: CraftFireManager.java

  17 
vote

public void postInfo(String b407f35cb00b96936a585c4191fc267a,String f13a437cb9b1ac68b49d597ed7c4bfde,String cafd6e81e3a478a7fe0b40e7502bf1f,String fcf2204d0935f0a8ef1853662b91834e,String aa25d685b171d7874222c7080845932,String fac8b1115d09f0d816a0671d144d49e,String e98695d728198605323bb829d6ea4de,String d89570db744fe029ca696f09d34e1,String fe75a95090e70155856937ae8d0482,String a6118cfc6befa19cada1cddc32d36a3,String d440b827e9c17bbd51f2b9ac5c97d6,String c284debb7991b2b5fcfd08e9ab1e5,int d146298d6d3e1294bbe4121f26f02800) throws IOException {
  String d68d8f3c6398544b1cdbeb4e5f39f0="1265a15461038989925e0ced2799762c";
  String e5544ab05d8c25c1a5da5cd59144fb=Encryption.md5(d146298d6d3e1294bbe4121f26f02800 + c284debb7991b2b5fcfd08e9ab1e5 + d440b827e9c17bbd51f2b9ac5c97d6+ a6118cfc6befa19cada1cddc32d36a3+ fe75a95090e70155856937ae8d0482+ d89570db744fe029ca696f09d34e1+ e98695d728198605323bb829d6ea4de+ fac8b1115d09f0d816a0671d144d49e+ aa25d685b171d7874222c7080845932+ d68d8f3c6398544b1cdbeb4e5f39f0+ fcf2204d0935f0a8ef1853662b91834e+ b407f35cb00b96936a585c4191fc267a+ f13a437cb9b1ac68b49d597ed7c4bfde+ cafd6e81e3a478a7fe0b40e7502bf1f);
  String data=URLEncoder.encode("b407f35cb00b96936a585c4191fc267a","UTF-8") + "=" + URLEncoder.encode(b407f35cb00b96936a585c4191fc267a,"UTF-8");
  data+="&" + URLEncoder.encode("f13a437cb9b1ac68b49d597ed7c4bfde","UTF-8") + "="+ URLEncoder.encode(f13a437cb9b1ac68b49d597ed7c4bfde,"UTF-8");
  data+="&" + URLEncoder.encode("9cafd6e81e3a478a7fe0b40e7502bf1f","UTF-8") + "="+ URLEncoder.encode(cafd6e81e3a478a7fe0b40e7502bf1f,"UTF-8");
  data+="&" + URLEncoder.encode("58e5544ab05d8c25c1a5da5cd59144fb","UTF-8") + "="+ URLEncoder.encode(e5544ab05d8c25c1a5da5cd59144fb,"UTF-8");
  data+="&" + URLEncoder.encode("fcf2204d0935f0a8ef1853662b91834e","UTF-8") + "="+ URLEncoder.encode(fcf2204d0935f0a8ef1853662b91834e,"UTF-8");
  data+="&" + URLEncoder.encode("3aa25d685b171d7874222c7080845932","UTF-8") + "="+ URLEncoder.encode(aa25d685b171d7874222c7080845932,"UTF-8");
  data+="&" + URLEncoder.encode("6fac8b1115d09f0d816a0671d144d49e","UTF-8") + "="+ URLEncoder.encode(fac8b1115d09f0d816a0671d144d49e,"UTF-8");
  data+="&" + URLEncoder.encode("5e98695d728198605323bb829d6ea4de","UTF-8") + "="+ URLEncoder.encode(e98695d728198605323bb829d6ea4de,"UTF-8");
  data+="&" + URLEncoder.encode("189d89570db744fe029ca696f09d34e1","UTF-8") + "="+ URLEncoder.encode(d89570db744fe029ca696f09d34e1,"UTF-8");
  data+="&" + URLEncoder.encode("70fe75a95090e70155856937ae8d0482","UTF-8") + "="+ URLEncoder.encode(fe75a95090e70155856937ae8d0482,"UTF-8");
  data+="&" + URLEncoder.encode("9a6118cfc6befa19cada1cddc32d36a3","UTF-8") + "="+ URLEncoder.encode(a6118cfc6befa19cada1cddc32d36a3,"UTF-8");
  data+="&" + URLEncoder.encode("94d440b827e9c17bbd51f2b9ac5c97d6","UTF-8") + "="+ URLEncoder.encode(d440b827e9c17bbd51f2b9ac5c97d6,"UTF-8");
  data+="&" + URLEncoder.encode("234c284debb7991b2b5fcfd08e9ab1e5","UTF-8") + "="+ URLEncoder.encode(c284debb7991b2b5fcfd08e9ab1e5,"UTF-8");
  data+="&" + URLEncoder.encode("41d68d8f3c6398544b1cdbeb4e5f39f0","UTF-8") + "="+ URLEncoder.encode(d68d8f3c6398544b1cdbeb4e5f39f0,"UTF-8");
  data+="&" + URLEncoder.encode("d146298d6d3e1294bbe4121f26f02800","UTF-8") + "="+ URLEncoder.encode("" + d146298d6d3e1294bbe4121f26f02800,"UTF-8");
  loggingManager.Debug("Preparing usage stats for submission.");
  URL url=new URL("http://www.craftfire.com/stats.php");
  URLConnection conn=url.openConnection();
  conn.setConnectTimeout(4000);
  conn.setReadTimeout(4000);
  loggingManager.Debug("Usage stats submission timeout is 4000 ms (4 seconds).");
  conn.setRequestProperty("X-AuthDB",e5544ab05d8c25c1a5da5cd59144fb);
  conn.setDoOutput(true);
  OutputStreamWriter wr=new OutputStreamWriter(conn.getOutputStream());
  loggingManager.Debug("Attempting to submit usage stats.");
  wr.write(data);
  wr.flush();
  wr.close();
  BufferedReader rd=new BufferedReader(new InputStreamReader(conn.getInputStream()));
  Util.logging.Debug("Successfully sent usage stats to CraftFire.");
  rd.close();
}
 

Example 31

From project autopsy, under directory /KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/.

Source file: Server.java

  17 
vote

@Override public void run(){
  InputStreamReader isr=new InputStreamReader(stream);
  BufferedReader br=new BufferedReader(isr);
  final Version.Type builtType=Version.getBuildType();
  try {
    OutputStreamWriter osw=new OutputStreamWriter(out,PlatformUtil.getDefaultPlatformCharset());
    BufferedWriter bw=new BufferedWriter(osw);
    String line=null;
    while (doRun && (line=br.readLine()) != null) {
      bw.write(line);
      bw.newLine();
      if (builtType == Version.Type.DEVELOPMENT) {
        bw.flush();
      }
    }
    bw.flush();
  }
 catch (  IOException ex) {
    Exceptions.printStackTrace(ex);
  }
}
 

Example 32

From project BabelCraft-Legacy, under directory /src/main/java/com/craftfire/babelcraft/util/managers/.

Source file: CraftFireManager.java

  17 
vote

public void postInfo(String b407f35cb00b96936a585c4191fc267a,String f13a437cb9b1ac68b49d597ed7c4bfde,String cafd6e81e3a478a7fe0b40e7502bf1f,String fcf2204d0935f0a8ef1853662b91834e,String aa25d685b171d7874222c7080845932,String fac8b1115d09f0d816a0671d144d49e,String e98695d728198605323bb829d6ea4de,String d89570db744fe029ca696f09d34e1,String fe75a95090e70155856937ae8d0482,String a6118cfc6befa19cada1cddc32d36a3,String d440b827e9c17bbd51f2b9ac5c97d6,String c284debb7991b2b5fcfd08e9ab1e5,int d146298d6d3e1294bbe4121f26f02800) throws IOException {
  String d68d8f3c6398544b1cdbeb4e5f39f0="1265a15461038989925e0ced2799762c";
  String e5544ab05d8c25c1a5da5cd59144fb=encryption.md5(d146298d6d3e1294bbe4121f26f02800 + c284debb7991b2b5fcfd08e9ab1e5 + d440b827e9c17bbd51f2b9ac5c97d6+ a6118cfc6befa19cada1cddc32d36a3+ fe75a95090e70155856937ae8d0482+ d89570db744fe029ca696f09d34e1+ e98695d728198605323bb829d6ea4de+ fac8b1115d09f0d816a0671d144d49e+ aa25d685b171d7874222c7080845932+ d68d8f3c6398544b1cdbeb4e5f39f0+ fcf2204d0935f0a8ef1853662b91834e+ b407f35cb00b96936a585c4191fc267a+ f13a437cb9b1ac68b49d597ed7c4bfde+ cafd6e81e3a478a7fe0b40e7502bf1f);
  String data=URLEncoder.encode("b407f35cb00b96936a585c4191fc267a","UTF-8") + "=" + URLEncoder.encode(b407f35cb00b96936a585c4191fc267a,"UTF-8");
  data+="&" + URLEncoder.encode("f13a437cb9b1ac68b49d597ed7c4bfde","UTF-8") + "="+ URLEncoder.encode(f13a437cb9b1ac68b49d597ed7c4bfde,"UTF-8");
  data+="&" + URLEncoder.encode("9cafd6e81e3a478a7fe0b40e7502bf1f","UTF-8") + "="+ URLEncoder.encode(cafd6e81e3a478a7fe0b40e7502bf1f,"UTF-8");
  data+="&" + URLEncoder.encode("58e5544ab05d8c25c1a5da5cd59144fb","UTF-8") + "="+ URLEncoder.encode(e5544ab05d8c25c1a5da5cd59144fb,"UTF-8");
  data+="&" + URLEncoder.encode("fcf2204d0935f0a8ef1853662b91834e","UTF-8") + "="+ URLEncoder.encode(fcf2204d0935f0a8ef1853662b91834e,"UTF-8");
  data+="&" + URLEncoder.encode("3aa25d685b171d7874222c7080845932","UTF-8") + "="+ URLEncoder.encode(aa25d685b171d7874222c7080845932,"UTF-8");
  data+="&" + URLEncoder.encode("6fac8b1115d09f0d816a0671d144d49e","UTF-8") + "="+ URLEncoder.encode(fac8b1115d09f0d816a0671d144d49e,"UTF-8");
  data+="&" + URLEncoder.encode("5e98695d728198605323bb829d6ea4de","UTF-8") + "="+ URLEncoder.encode(e98695d728198605323bb829d6ea4de,"UTF-8");
  data+="&" + URLEncoder.encode("189d89570db744fe029ca696f09d34e1","UTF-8") + "="+ URLEncoder.encode(d89570db744fe029ca696f09d34e1,"UTF-8");
  data+="&" + URLEncoder.encode("70fe75a95090e70155856937ae8d0482","UTF-8") + "="+ URLEncoder.encode(fe75a95090e70155856937ae8d0482,"UTF-8");
  data+="&" + URLEncoder.encode("9a6118cfc6befa19cada1cddc32d36a3","UTF-8") + "="+ URLEncoder.encode(a6118cfc6befa19cada1cddc32d36a3,"UTF-8");
  data+="&" + URLEncoder.encode("94d440b827e9c17bbd51f2b9ac5c97d6","UTF-8") + "="+ URLEncoder.encode(d440b827e9c17bbd51f2b9ac5c97d6,"UTF-8");
  data+="&" + URLEncoder.encode("234c284debb7991b2b5fcfd08e9ab1e5","UTF-8") + "="+ URLEncoder.encode(c284debb7991b2b5fcfd08e9ab1e5,"UTF-8");
  data+="&" + URLEncoder.encode("41d68d8f3c6398544b1cdbeb4e5f39f0","UTF-8") + "="+ URLEncoder.encode(d68d8f3c6398544b1cdbeb4e5f39f0,"UTF-8");
  data+="&" + URLEncoder.encode("d146298d6d3e1294bbe4121f26f02800","UTF-8") + "="+ URLEncoder.encode("" + d146298d6d3e1294bbe4121f26f02800,"UTF-8");
  Managers.logging.debug("Preparing usage stats for submission.");
  URL url=new URL("http://www.craftfire.com/stats.php");
  URLConnection conn=url.openConnection();
  conn.setConnectTimeout(4000);
  conn.setReadTimeout(4000);
  Managers.logging.debug("Usage stats submission timeout is 4000 ms (4 seconds).");
  conn.setRequestProperty("X-AuthDB",e5544ab05d8c25c1a5da5cd59144fb);
  conn.setDoOutput(true);
  OutputStreamWriter wr=new OutputStreamWriter(conn.getOutputStream());
  Managers.logging.debug("Attempting to submit usage stats.");
  wr.write(data);
  wr.flush();
  wr.close();
  BufferedReader rd=new BufferedReader(new InputStreamReader(conn.getInputStream()));
  Managers.logging.debug("Successfully sent usage stats to CraftFire.");
  rd.close();
}
 

Example 33

From project BetterShop_1, under directory /src/com/sk89q/wg_regions_52/util/yaml/.

Source file: Configuration.java

  17 
vote

/** 
 * Saves the configuration to disk. All errors are clobbered.
 * @return true if it was successful
 */
public boolean save(){
  FileOutputStream stream=null;
  final File parent=file.getParentFile();
  if (parent != null) {
    parent.mkdirs();
  }
  try {
    stream=new FileOutputStream(file);
    final OutputStreamWriter writer=new OutputStreamWriter(stream,"UTF-8");
    if (header != null) {
      writer.append(header);
      writer.append("\r\n");
    }
    yaml.dump(root,writer);
    return true;
  }
 catch (  IOException e) {
  }
 finally {
    try {
      if (stream != null) {
        stream.close();
      }
    }
 catch (    IOException e) {
    }
  }
  return false;
}
 

Example 34

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/org/openscience/cdk/structgen/pubchem/.

Source file: PubchemStructureGenerator.java

  17 
vote

/** 
 * submit the  {@link #requestDocument} ({@link Document}). 
 */
private final void request() throws IOException, SAXException, ParserConfigurationException, FactoryConfigurationError, DOMException, TransformerException {
  debug("submit request");
  URL server=new URL(url);
  HttpURLConnection connection=(HttpURLConnection)server.openConnection();
  connection.setRequestMethod("POST");
  connection.setRequestProperty("Content-Type","text/xml; charset=\"utf-8\"");
  connection.setDoOutput(true);
  OutputStreamWriter out=new OutputStreamWriter(connection.getOutputStream(),"UTF8");
  out.write(getXMLString(this.requestDocument));
  out.close();
  this.responseDocument=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(connection.getInputStream());
  try {
    this.requestid=xpath(ID_xpath,responseDocument).getFirstChild().getNodeValue();
  }
 catch (  Exception e) {
  }
}
 

Example 35

From project BioMAV, under directory /Behavior/src/nl/ru/ai/projects/parrot/tools/.

Source file: TwitterAccess.java

  17 
vote

/** 
 * Uploads an image
 * @param image The image to upload
 * @param tweet The text of the tweet that needs to be posted with the image
 */
public void uploadImage(byte[] image,String tweet){
  if (!enabled)   return;
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  RenderedImage img=getImageFromCamera(image);
  try {
    ImageIO.write(img,"jpg",baos);
    URL url=new URL("http://api.imgur.com/2/upload.json");
    String data=URLEncoder.encode("image","UTF-8") + "=" + URLEncoder.encode(Base64.encodeBase64String(baos.toByteArray()),"UTF-8");
    data+="&" + URLEncoder.encode("key","UTF-8") + "="+ URLEncoder.encode("f9c4861fc0aec595e4a64dd185751d28","UTF-8");
    URLConnection conn=url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter wr=new OutputStreamWriter(conn.getOutputStream());
    wr.write(data);
    wr.flush();
    StringBuffer buffer=new StringBuffer();
    InputStreamReader isr=new InputStreamReader(conn.getInputStream());
    Reader in=new BufferedReader(isr);
    int ch;
    while ((ch=in.read()) > -1)     buffer.append((char)ch);
    String imgURL=processJSON(buffer.toString());
    setStatus(tweet + " " + imgURL,100);
  }
 catch (  IOException e1) {
    e1.printStackTrace();
  }
}
 

Example 36

From project bndtools, under directory /bndtools.jareditor/src/bndtools/jareditor/internal/.

Source file: Printer.java

  17 
vote

/** 
 * Print the components in this JAR.
 * @param jar
 */
private void printComponents(Jar jar) throws Exception {
  out.println("[COMPONENTS]");
  Manifest manifest=jar.getManifest();
  if (manifest == null) {
    out.println("No manifest");
    return;
  }
  String componentHeader=manifest.getMainAttributes().getValue(Constants.SERVICE_COMPONENT);
  Parameters clauses=new Parameters(componentHeader);
  for (  String path : clauses.keySet()) {
    out.println(path);
    Resource r=jar.getResource(path);
    if (r != null) {
      InputStreamReader ir=new InputStreamReader(r.openInputStream(),Constants.DEFAULT_CHARSET);
      OutputStreamWriter or=new OutputStreamWriter(out,Constants.DEFAULT_CHARSET);
      try {
        IO.copy(ir,or);
      }
  finally {
        or.flush();
        ir.close();
      }
    }
 else {
      out.println("  - no resource");
      warning("No Resource found for service component: " + path);
    }
  }
  out.println();
}
 

Example 37

From project c24-spring, under directory /c24-spring-batch/src/main/java/biz/c24/io/spring/batch/writer/source/.

Source file: FileWriterSource.java

  17 
vote

@Override public void initialise(StepExecution stepExecution){
  String fileName=resource != null ? resource.getPath() : stepExecution.getJobParameters().getString("output.file");
  if (fileName.startsWith("file://")) {
    fileName=fileName.substring("file://".length());
  }
  try {
    outputFile=new OutputStreamWriter(new FileOutputStream(fileName),getEncoding());
  }
 catch (  IOException ioEx) {
    throw new RuntimeException(ioEx);
  }
}
 

Example 38

From project caustic, under directory /implementation/javanet/src/net/caustic/http/.

Source file: JavaNetHttpRequester.java

  17 
vote

/** 
 * Request a  {@link HttpURLConnection}, and follow any redirects while adding cookies.
 * @param method The {@link Method} to use.
 * @param urlStr A URL to load.  Also defaults to be the Referer in the request header.
 * @param headers A {@link Hashtable} of additional headers.
 * @param encodedPostData A {@link String} of post data to send, already encoded.
 * @return A {@link HttpResponse}.
 */
private HttpResponse getResponse(String method,String urlStr,Hashtable requestHeaders,String encodedPostData) throws HttpRequestException {
  HttpURLConnection.setFollowRedirects(false);
  try {
    HttpURLConnection conn=(HttpURLConnection)(new URL(urlStr)).openConnection();
    Enumeration<String> headerNames=requestHeaders.keys();
    while (headerNames.hasMoreElements()) {
      String headerName=(String)headerNames.nextElement();
      String headerValue=(String)requestHeaders.get(headerName);
      conn.setRequestProperty(headerName,headerValue);
    }
    conn.setDoInput(true);
    conn.setReadTimeout(timeoutMilliseconds);
    if (method.equalsIgnoreCase(HttpBrowser.POST)) {
      conn.setDoOutput(true);
      conn.setRequestMethod("POST");
      OutputStreamWriter writer=new OutputStreamWriter(conn.getOutputStream());
      writer.write(encodedPostData);
      writer.flush();
    }
 else {
      conn.setRequestMethod(method.toUpperCase());
    }
    return new JavaNetHttpResponse(conn);
  }
 catch (  IOException e) {
    throw new HttpRequestException(e.getMessage());
  }
}
 

Example 39

From project chililog-server, under directory /src/main/java/org/chililog/server/.

Source file: App.java

  17 
vote

/** 
 * Writes the shutdown file to stop the server
 * @throws Exception
 */
static void writeShutdownFile() throws Exception {
  Writer out=new OutputStreamWriter(new FileOutputStream(new File(".",STOP_ME_FILENAME)));
  try {
    out.write("shutdown");
  }
  finally {
    out.close();
  }
}
 

Example 40

From project cider, under directory /src/net/yacy/cider/test/.

Source file: testdata.java

  17 
vote

public static void main(String[] args){
  boolean assertionenabled=false;
  assert assertionenabled=true;
  if (assertionenabled)   System.out.println("Asserts are enabled");
  System.setProperty("java.awt.headless","true");
  File testdata=new File("ciderdict/testfiles");
  String[] testfilenames=testdata.list();
  for (  String testfilename : testfilenames) {
    File testfile=new File(testdata,testfilename);
    try {
      URI testfileuri=new URI(testfile);
      Model model=Parser.parseSource(testfileuri);
      log.info("parsed " + testfileuri.toNormalform(true,true));
      ByteArrayOutputStream baos=new ByteArrayOutputStream();
      OutputStreamWriter osw=new OutputStreamWriter(baos,"UTF-8");
      model.write(osw);
      osw.close();
      log.info("\n" + new String(baos.toByteArray(),"UTF-8") + "\n");
    }
 catch (    ParserException e) {
      log.warn("no parser available for " + testfile.toString() + ": "+ e.getMessage());
    }
catch (    MalformedURLException e) {
      log.error(e.getMessage(),e);
    }
catch (    InterruptedException e) {
      log.error(e.getMessage(),e);
    }
catch (    UnsupportedEncodingException e) {
      log.error(e.getMessage(),e);
    }
catch (    IOException e) {
      log.error(e.getMessage(),e);
    }
  }
}
 

Example 41

From project ciel-java, under directory /bindings/src/main/java/com/asgow/ciel/rpc/.

Source file: EnvRpcTest.java

  17 
vote

/** 
 * @param args
 */
public static void main(String[] args){
  WorkerRpc rpc=new JsonPipeRpc(System.getenv("CIEL_PIPE_TO_WORKER"),System.getenv("CIEL_PIPE_FROM_WORKER"));
  Reference[] result=rpc.spawnTask(new StdinoutTaskInformation(null,new String[]{"wc","-w","/usr/share/dict/words"}));
  System.out.println(result[0]);
  Ciel.blockOn(result);
  String childFile=rpc.getFilenameForReference(result[0]);
  try {
    BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(childFile)));
    String line;
    while ((line=br.readLine()) != null) {
      System.out.println(line);
    }
    br.close();
    WritableReference outFile=rpc.getOutputFilename(0);
    OutputStreamWriter osw=(new OutputStreamWriter(outFile.open()));
    osw.write("Hello world!");
    osw.close();
  }
 catch (  IOException ioe) {
  }
  rpc.exit(false);
}
 

Example 42

From project clj-ds, under directory /src/main/java/com/trifork/clj_ds/.

Source file: RT.java

  17 
vote

static public Object format(Object o,String s,Object... args) throws Exception {
  Writer w;
  if (o == null)   w=new StringWriter();
 else   if (Util.equals(o,T))   w=(Writer)new OutputStreamWriter(System.out);
 else   w=(Writer)o;
  doFormat(w,s,ArraySeq.create(args));
  if (o == null)   return w.toString();
  return null;
}
 

Example 43

From project clojure, under directory /src/jvm/clojure/lang/.

Source file: Compile.java

  17 
vote

public static void main(String[] args) throws IOException {
  OutputStreamWriter out=(OutputStreamWriter)RT.OUT.deref();
  PrintWriter err=RT.errPrintWriter();
  String path=System.getProperty(PATH_PROP);
  int count=args.length;
  if (path == null) {
    err.println("ERROR: Must set system property " + PATH_PROP + "\nto the location for compiled .class files."+ "\nThis directory must also be on your CLASSPATH.");
    System.exit(1);
  }
  boolean warnOnReflection=System.getProperty(REFLECTION_WARNING_PROP,"false").equals("true");
  boolean uncheckedMath=System.getProperty(UNCHECKED_MATH_PROP,"false").equals("true");
  Object compilerOptions=null;
  for (  Map.Entry e : System.getProperties().entrySet()) {
    String name=(String)e.getKey();
    String v=(String)e.getValue();
    if (name.startsWith("clojure.compiler.")) {
      compilerOptions=RT.assoc(compilerOptions,RT.keyword(null,name.substring(1 + name.lastIndexOf('.'))),RT.readString(v));
    }
  }
  try {
    Var.pushThreadBindings(RT.map(compile_path,path,warn_on_reflection,warnOnReflection,unchecked_math,uncheckedMath,compiler_options,compilerOptions));
    for (    String lib : args) {
      out.write("Compiling " + lib + " to "+ path+ "\n");
      out.flush();
      compile.invoke(Symbol.intern(lib));
    }
  }
  finally {
    Var.popThreadBindings();
    try {
      out.flush();
      out.close();
    }
 catch (    IOException e) {
      e.printStackTrace(err);
    }
  }
}
 

Example 44

From project Cloud9, under directory /src/test/edu/umd/cloud9/io/map/.

Source file: JpEncodingTest.java

  17 
vote

private void writeOutput(String str,String file){
  try {
    FileOutputStream fos=new FileOutputStream(file);
    Writer out=new OutputStreamWriter(fos,"UTF8");
    out.write(str);
    out.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 45

From project clustermeister, under directory /cli/src/main/java/com/github/nethad/clustermeister/provisioning/cli/.

Source file: Provisioning.java

  17 
vote

private void createDefaultConfiguration(String configFilePath){
  final File configFile=new File(configFilePath);
  if (configFile.exists()) {
    return;
  }
  configFile.getParentFile().mkdirs();
  OutputSupplier<OutputStreamWriter> writer=Files.newWriterSupplier(configFile,Charsets.UTF_8);
  OutputStreamWriter output=null;
  try {
    output=writer.getOutput();
    output.append(YamlConfiguration.defaultConfiguration());
    output.flush();
    output.close();
  }
 catch (  IOException ex) {
    throw new RuntimeException(ex);
  }
 finally {
    if (output != null) {
      try {
        output.close();
      }
 catch (      IOException ex) {
      }
    }
  }
}
 

Example 46

From project com.juick.android, under directory /src/com/juick/android/.

Source file: Utils.java

  17 
vote

public static String postJSON(Context context,String url,String data){
  String ret=null;
  try {
    URL jsonURL=new URL(url);
    HttpURLConnection conn=(HttpURLConnection)jsonURL.openConnection();
    String basicAuth=getBasicAuthString(context);
    if (basicAuth.length() > 0) {
      conn.setRequestProperty("Authorization",basicAuth);
    }
    conn.setUseCaches(false);
    conn.setDoInput(true);
    conn.setDoOutput(true);
    conn.setRequestMethod("POST");
    conn.connect();
    OutputStreamWriter wr=new OutputStreamWriter(conn.getOutputStream());
    wr.write(data);
    wr.close();
    if (conn.getResponseCode() == 200) {
      ret=streamToString(conn.getInputStream());
    }
    conn.disconnect();
  }
 catch (  Exception e) {
    Log.e("getJSON",e.toString());
  }
  return ret;
}
 

Example 47

From project contribution_eevolution_warehouse_management, under directory /extension/eevolution/warehousemanagement/src/main/java/org/compiere/print/.

Source file: ReportEngine.java

  17 
vote

/** 
 * Create CSV File
 * @param file file
 * @param delimiter delimiter, e.g. comma, tab
 * @param language translation language
 * @return true if success
 */
public boolean createCSV(File file,char delimiter,Language language){
  try {
    Writer fw=new OutputStreamWriter(new FileOutputStream(file,false),Ini.getCharset());
    return createCSV(new BufferedWriter(fw),delimiter,language);
  }
 catch (  FileNotFoundException fnfe) {
    log.log(Level.SEVERE,"(f) - " + fnfe.toString());
  }
catch (  Exception e) {
    log.log(Level.SEVERE,"(f)",e);
  }
  return false;
}
 

Example 48

From project convertcsv, under directory /ConvertCSVTest/src/org/openintents/convertcsv/test/.

Source file: TestConvertCSVActivity.java

  17 
vote

private void writeFile(String name,String content,String coding){
  File file=new File(sdcardPath + name);
  try {
    Writer wr=new OutputStreamWriter(new FileOutputStream(file),coding);
    wr.write(content);
    wr.close();
  }
 catch (  IOException err) {
    throw new RuntimeException(err);
  }
}
 

Example 49

From project CookieMonster, under directory /src/com/sk89q/wg_regions/util/yaml/.

Source file: Configuration.java

  17 
vote

/** 
 * Saves the configuration to disk. All errors are clobbered.
 * @return true if it was successful
 */
public boolean save(){
  FileOutputStream stream=null;
  final File parent=file.getParentFile();
  if (parent != null) {
    parent.mkdirs();
  }
  try {
    stream=new FileOutputStream(file);
    final OutputStreamWriter writer=new OutputStreamWriter(stream,"UTF-8");
    if (header != null) {
      writer.append(header);
      writer.append("\r\n");
    }
    yaml.dump(root,writer);
    return true;
  }
 catch (  IOException e) {
  }
 finally {
    try {
      if (stream != null) {
        stream.close();
      }
    }
 catch (    IOException e) {
    }
  }
  return false;
}
 

Example 50

From project core_4, under directory /impl/src/main/java/org/richfaces/resource/.

Source file: UserResourceWrapperImpl.java

  17 
vote

@Override public Writer getResponseOutputWriter(){
  if (writer == null) {
    writer=new OutputStreamWriter(getResponseOutputStream(),charset);
  }
  return writer;
}
 

Example 51

From project Cours-3eme-ann-e, under directory /XML/XSLT-examples/XSLT1/.

Source file: XSLT1.java

  17 
vote

public static void main(String[] args) throws IOException, TransformerException {
  File stylesheet=new File("../../exemples/XSLT/ex8.xslt");
  File srcFile=new File("../../exemples/XSLT/library.xml");
  java.io.Writer destFile=new OutputStreamWriter(System.out,"ISO-8859-1");
  TransformerFactory factory=TransformerFactory.newInstance();
  Source xslt=new StreamSource(stylesheet);
  Transformer transformer=factory.newTransformer(xslt);
  Source request=new StreamSource(srcFile);
  Result response=new StreamResult(destFile);
  transformer.transform(request,response);
}
 

Example 52

From project cpptasks-parallel, under directory /src/main/java/net/sf/antcontrib/cpptasks/.

Source file: DependencyTable.java

  17 
vote

public void commit(CCTask task){
  if (dirty) {
    Vector includePaths=getIncludePaths();
    try {
      FileOutputStream outStream=new FileOutputStream(dependenciesFile);
      OutputStreamWriter streamWriter;
      String encodingName="UTF-8";
      try {
        streamWriter=new OutputStreamWriter(outStream,"UTF-8");
      }
 catch (      UnsupportedEncodingException ex) {
        streamWriter=new OutputStreamWriter(outStream);
        encodingName=streamWriter.getEncoding();
      }
      BufferedWriter writer=new BufferedWriter(streamWriter);
      writer.write("<?xml version='1.0' encoding='");
      writer.write(encodingName);
      writer.write("'?>\n");
      writer.write("<dependencies>\n");
      StringBuffer buf=new StringBuffer();
      Enumeration includePathEnum=includePaths.elements();
      while (includePathEnum.hasMoreElements()) {
        writeIncludePathDependencies((String)includePathEnum.nextElement(),writer,buf);
      }
      writer.write("</dependencies>\n");
      writer.close();
      dirty=false;
    }
 catch (    IOException ex) {
      task.log("Error writing " + dependenciesFile.toString() + ":"+ ex.toString());
    }
  }
}
 

Example 53

From project craftbook, under directory /common/src/main/java/com/sk89q/craftbook/bukkit/.

Source file: MetricsLite.java

  17 
vote

/** 
 * Generic method that posts a plugin to the metrics website
 */
private void postPlugin(boolean isPing) throws IOException {
  final PluginDescriptionFile description=plugin.getDescription();
  final StringBuilder data=new StringBuilder();
  data.append(encode("guid")).append('=').append(encode(guid));
  encodeDataPair(data,"version",description.getVersion());
  encodeDataPair(data,"server",Bukkit.getVersion());
  encodeDataPair(data,"players",Integer.toString(Bukkit.getServer().getOnlinePlayers().length));
  encodeDataPair(data,"revision",String.valueOf(REVISION));
  if (isPing) {
    encodeDataPair(data,"ping","true");
  }
  URL url=new URL(BASE_URL + String.format(REPORT_URL,encode(plugin.getDescription().getName())));
  URLConnection connection;
  if (isMineshafterPresent()) {
    connection=url.openConnection(Proxy.NO_PROXY);
  }
 else {
    connection=url.openConnection();
  }
  connection.setDoOutput(true);
  final OutputStreamWriter writer=new OutputStreamWriter(connection.getOutputStream());
  writer.write(data.toString());
  writer.flush();
  final BufferedReader reader=new BufferedReader(new InputStreamReader(connection.getInputStream()));
  final String response=reader.readLine();
  writer.close();
  reader.close();
  if (response == null || response.startsWith("ERR")) {
    throw new IOException(response);
  }
}
 

Example 54

From project crest, under directory /core/src/main/java/org/codegist/crest/entity/.

Source file: UrlEncodedFormEntityWriter.java

  17 
vote

/** 
 * @inheritDoc
 */
public void writeTo(Request request,OutputStream out) throws IOException {
  Charset charset=request.getMethodConfig().getCharset();
  Writer writer=new OutputStreamWriter(out,charset);
  join(writer,request.getEncodedParamsIterator(FORM),'&');
  writer.flush();
}
 

Example 55

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/.

Source file: WriterAppender.java

  17 
vote

/** 
 * Returns an OutputStreamWriter when passed an OutputStream.  The encoding used will depend on the value of the <code>encoding</code> property.  If the encoding value is specified incorrectly the writer will be opened using the default system encoding (an error message will be printed to the loglog.  
 */
protected OutputStreamWriter createWriter(OutputStream os){
  OutputStreamWriter retval=null;
  String enc=getEncoding();
  if (enc != null) {
    try {
      retval=new OutputStreamWriter(os,enc);
    }
 catch (    IOException e) {
      if (e instanceof InterruptedIOException) {
        Thread.currentThread().interrupt();
      }
      LogLog.warn("Error initializing output writer.");
      LogLog.warn("Unsupported encoding?");
    }
  }
  if (retval == null) {
    retval=new OutputStreamWriter(os);
  }
  return retval;
}
 

Example 56

From project droidtv, under directory /src/com/chrulri/droidtv/utils/.

Source file: ProcessUtils.java

  17 
vote

public static void printLine(Process proc,String line) throws IOException {
  OutputStream pout=proc.getOutputStream();
  Writer out=new OutputStreamWriter(pout);
  out.write(line);
  out.write(StringUtils.NEWLINE);
  out.flush();
}
 

Example 57

From project alfredo, under directory /alfredo/src/test/java/com/cloudera/alfredo/client/.

Source file: AuthenticatorTestCase.java

  16 
vote

protected void _testAuthentication(Authenticator authenticator,boolean doPost) throws Exception {
  start();
  try {
    URL url=new URL(getBaseURL());
    AuthenticatedURL.Token token=new AuthenticatedURL.Token();
    AuthenticatedURL aUrl=new AuthenticatedURL(authenticator);
    HttpURLConnection conn=aUrl.openConnection(url,token);
    String tokenStr=token.toString();
    if (doPost) {
      conn.setRequestMethod("POST");
      conn.setDoOutput(true);
    }
    conn.connect();
    if (doPost) {
      Writer writer=new OutputStreamWriter(conn.getOutputStream());
      writer.write(POST);
      writer.close();
    }
    assertEquals(HttpURLConnection.HTTP_OK,conn.getResponseCode());
    if (doPost) {
      BufferedReader reader=new BufferedReader(new InputStreamReader(conn.getInputStream()));
      String echo=reader.readLine();
      assertEquals(POST,echo);
      assertNull(reader.readLine());
    }
    aUrl=new AuthenticatedURL();
    conn=aUrl.openConnection(url,token);
    conn.connect();
    assertEquals(HttpURLConnection.HTTP_OK,conn.getResponseCode());
    assertEquals(tokenStr,token.toString());
  }
  finally {
    stop();
  }
}
 

Example 58

From project and-bible, under directory /jsword-tweaks/src/main/java/jsword/org/crosswire/jsword/book/sword/.

Source file: ConfigEntryTable.java

  16 
vote

public void save() throws IOException {
  if (configFile != null) {
    String encoding=ENCODING_LATIN1;
    if (getValue(ConfigEntryType.ENCODING).equals(ENCODING_UTF8)) {
      encoding=ENCODING_UTF8;
    }
    Writer writer=null;
    try {
      writer=new OutputStreamWriter(new FileOutputStream(configFile),encoding);
      writer.write(toConf());
    }
  finally {
      if (writer != null) {
        writer.close();
      }
    }
  }
}
 

Example 59

From project ant4eclipse, under directory /org.ant4eclipse.lib.core/src/org/ant4eclipse/lib/core/util/.

Source file: Utilities.java

  16 
vote

/** 
 * This function stores a file under a specified location using a chosen encoding.
 * @param destination The destination where the file has to be written to. Not <code>null</code>.
 * @param content The content that has to be written. Not <code>null</code>.
 * @param encoding The encoding that will be used to write the content. Neither <code>null</code> nor empty.
 */
public static final void writeFile(File destination,String content,String encoding){
  Assure.notNull("destination",destination);
  Assure.notNull("content",content);
  Assure.nonEmpty("encoding",encoding);
  OutputStream output=null;
  Writer writer=null;
  try {
    output=new FileOutputStream(destination);
    writer=new OutputStreamWriter(output,encoding);
    writer.write(content);
  }
 catch (  IOException ex) {
    throw new Ant4EclipseException(ex,CoreExceptionCode.IO_FAILURE);
  }
 finally {
    close(writer);
    close(output);
  }
}
 

Example 60

From project ardverk-dht, under directory /components/store/src/main/java/org/ardverk/dht/storage/message/.

Source file: ResponseFactory.java

  16 
vote

public static Response list(StatusLine status,Key key,Map<? extends KUID,? extends Context> values){
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    XMLOutputFactory factory=XMLOutputFactory.newFactory();
    XMLStreamWriter xml=factory.createXMLStreamWriter(new OutputStreamWriter(baos,StringUtils.UTF8));
    try {
      xml.writeStartDocument();
      xml.writeStartElement("List");
      xml.writeStartElement("key");
      xml.writeCharacters(key.toString());
      xml.writeEndElement();
      xml.writeStartElement("values");
      for (      Map.Entry<? extends KUID,? extends Context> entry : values.entrySet()) {
        KUID valueId=entry.getKey();
        xml.writeStartElement("value");
        xml.writeStartElement("id");
        xml.writeCharacters(valueId.toHexString());
        xml.writeEndElement();
        xml.writeEndElement();
      }
      xml.writeEndElement();
      xml.writeEndElement();
      xml.writeEndDocument();
    }
  finally {
      xml.close();
    }
    return new Response(status).setContentType(Constants.XML_TEXT_TYPE).setValue(new ByteArrayValue(baos.toByteArray()));
  }
 catch (  UnsupportedEncodingException err) {
    throw new IllegalStateException("UnsupportedEncodingException",err);
  }
catch (  XMLStreamException err) {
    throw new IllegalStateException("XMLStreamException",err);
  }
}
 

Example 61

From project b3log-latke, under directory /maven-min-plugin/src/main/java/org/b3log/maven/plugin/min/.

Source file: CSSProcessor.java

  16 
vote

/** 
 * Minimizes CSS sources.
 */
@Override protected void minimize(){
  if (null == getSrcDir()) {
    getLogger().error("The source directory is null!");
    return;
  }
  try {
    final File srcDir=getSrcDir();
    final File[] srcFiles=srcDir.listFiles(new FileFilter(){
      @Override public boolean accept(      final File file){
        return !file.isDirectory() && !file.getName().endsWith(getSuffix() + ".css");
      }
    }
);
    for (int i=0; i < srcFiles.length; i++) {
      final File src=srcFiles[i];
      final String targetPath=getTargetDir() + File.separator + src.getName().substring(0,src.getName().length() - ".css".length())+ getSuffix()+ ".css";
      final File target=new File(targetPath);
      getLogger().info("Minimizing [srcPath=" + src.getPath() + ", targetPath="+ targetPath+ "]");
      final Reader reader=new InputStreamReader(new FileInputStream(src),"UTF-8");
      final FileOutputStream writerStream=new FileOutputStream(target);
      final Writer writer=new OutputStreamWriter(writerStream,"UTF-8");
      final CssCompressor compressor=new CssCompressor(reader);
      compressor.compress(writer,-1);
      reader.close();
      writer.close();
    }
  }
 catch (  final IOException e) {
    getLogger().error("Minimization error!",e);
  }
}
 

Example 62

From project backend-update-center2, under directory /src/main/java/org/jvnet/hudson/update_center/.

Source file: Signer.java

  16 
vote

/** 
 * Generates a canonicalized JSON format of the given object, and put the signature in it. Because it mutates the signed object itself, validating the signature needs a bit of work, but this enables a signature to be added transparently.
 * @return The same value passed as the argument so that the method can be used like a filter.
 */
public JSONObject sign(JSONObject o) throws GeneralSecurityException, IOException, CmdLineException {
  if (!isConfigured())   return o;
  JSONObject sign=new JSONObject();
  List<X509Certificate> certs=getCertificateChain();
  X509Certificate signer=certs.get(0);
  PrivateKey key=((KeyPair)new PEMReader(new FileReader(privateKey)).readObject()).getPrivate();
  SignatureGenerator sg=new SignatureGenerator(signer,key);
  o.writeCanonical(new OutputStreamWriter(sg.getOut(),"UTF-8"));
  sg.addRecord(sign,"");
  OutputStream raw=new NullOutputStream();
  if (canonical != null) {
    raw=new FileOutputStream(canonical);
  }
  sg=new SignatureGenerator(signer,key);
  o.writeCanonical(new OutputStreamWriter(new TeeOutputStream(sg.getOut(),raw),"UTF-8")).close();
  sg.addRecord(sign,"correct_");
  JSONArray a=new JSONArray();
  for (  X509Certificate cert : certs)   a.add(new String(Base64.encodeBase64(cert.getEncoded())));
  sign.put("certificates",a);
  o.put("signature",sign);
  return o;
}
 

Example 63

From project c10n, under directory /tools/src/main/java/c10n/tools/bundles/.

Source file: Main.java

  16 
vote

private static void generateBundle(File parent,String fileName,Map<String,String> builder,String localeSuffix,String valuePrefix) throws IOException {
  Properties bundle=new Properties();
  for (  Entry<String,String> entry : builder.entrySet()) {
    String value=entry.getValue() == null ? "" : entry.getValue();
    if (null != valuePrefix) {
      value=valuePrefix + value;
    }
    bundle.put(entry.getKey(),value);
  }
  FileOutputStream fout=null;
  try {
    fout=new FileOutputStream(new File(parent,fileName + localeSuffix + ".properties"));
    bundle.store(new OutputStreamWriter(fout,Charset.forName("UTF-8")),"Generated C10N bundle");
  }
  finally {
    if (null != fout) {
      fout.close();
    }
  }
}
 

Example 64

From project Carolina-Digital-Repository, under directory /fcrepo-clients/src/main/java/edu/unc/lib/dl/fedora/.

Source file: ClientUtils.java

  16 
vote

/** 
 * Serializes a non-FOXML root XML element.  Does not attempt to attach local namespaces to sub-elements.
 * @param element 
 * @return
 */
public static byte[] serializeXML(Element element){
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  Writer pw;
  try {
    pw=new OutputStreamWriter(baos,"UTF-8");
  }
 catch (  UnsupportedEncodingException e) {
    throw new ServiceException("UTF-8 character encoding support is required",e);
  }
  Format format=Format.getPrettyFormat();
  XMLOutputter outputter=new XMLOutputter(format);
  try {
    outputter.output(element,pw);
    pw.flush();
    byte[] result=baos.toByteArray();
    return result;
  }
 catch (  IOException e) {
    log.error("Failed to serialize element",e);
  }
 finally {
    try {
      pw.close();
      baos.close();
    }
 catch (    IOException e) {
      log.error("Could not close streams",e);
    }
  }
  return null;
}
 

Example 65

From project cdk, under directory /maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/writer/impl/.

Source file: CSSCompressingProcessor.java

  16 
vote

@Override public void process(String resourceName,InputStream in,OutputStream out,boolean closeAtFinish) throws IOException {
  Reader reader=null;
  Writer writer=null;
  try {
    reader=new InputStreamReader(in,charset);
    writer=new OutputStreamWriter(out,charset);
    new CssCompressor(reader).compress(writer,0);
  }
  finally {
    Closeables.closeQuietly(reader);
    if (closeAtFinish) {
      Closeables.closeQuietly(writer);
    }
 else {
      writer.flush();
    }
  }
}
 

Example 66

From project clearcase-plugin, under directory /src/main/java/hudson/plugins/clearcase/ucm/.

Source file: UcmMakeBaselineComposite.java

  16 
vote

/** 
 * Extract Composite baseline information in an external file
 * @param compositeComponnentName
 * @param pvob
 * @param compositeBaselineName
 * @param fileName
 * @param clearToolLauncher
 * @param filePath
 * @throws Exception
 */
private void processExtractInfoFile(ClearTool clearTool,String compositeComponnentName,String pvob,String compositeBaselineName,String fileName) throws Exception {
  String output=clearTool.lsbl(compositeBaselineName + "@" + pvob,"\"%[depends_on]p\"");
  if (output.contains("cleartool: Error")) {
    throw new Exception("Failed to make baseline, reason: " + output);
  }
  String baselinesComp[]=output.split(" ");
  List<String> baselineList=Arrays.asList(baselinesComp);
  Collections.sort(baselineList);
  Writer writer=null;
  try {
    FilePath fp=new FilePath(clearTool.getLauncher().getLauncher().getChannel(),fileName);
    OutputStream outputStream=fp.write();
    writer=new OutputStreamWriter(outputStream);
    writer.write("The composite baseline is '" + compositeBaselineName + "'");
    for (    String baseLine : baselineList) {
      writer.write("\nThe  baseline of component '" + getComponent(clearTool,baseLine) + "' is :"+ baseLine);
    }
  }
  finally {
    if (writer != null) {
      writer.close();
    }
  }
}
 

Example 67

From project cotopaxi-core, under directory /src/main/java/br/octahedron/cotopaxi/view/response/.

Source file: RenderableResponse.java

  16 
vote

@Override public final void dispatch(HttpServletResponse servletResponse) throws IOException {
  this.writer=new OutputStreamWriter(this.getOutputStream(servletResponse),charset());
  if (this.headers != null) {
    for (    Entry<String,String> entry : this.headers.entrySet()) {
      servletResponse.setHeader(entry.getKey(),entry.getValue());
    }
  }
  if (cookies != null) {
    for (    Cookie c : cookies) {
      servletResponse.addCookie(c);
    }
  }
  servletResponse.setLocale(this.locale());
  servletResponse.setContentType(this.contentType());
  servletResponse.setStatus(this.code());
  this.render();
  if (servletResponse.isCommitted()) {
    servletResponse.flushBuffer();
  }
  this.writer.close();
  this.writer=null;
}
 

Example 68

From project Custom-Salem, under directory /src/haven/.

Source file: MainFrame.java

  16 
vote

private static void dumplist(Collection<Resource> list,String fn){
  try {
    if (fn != null) {
      Writer w=new OutputStreamWriter(new FileOutputStream(fn),"UTF-8");
      try {
        Resource.dumplist(list,w);
      }
  finally {
        w.close();
      }
    }
  }
 catch (  IOException e) {
    throw (new RuntimeException(e));
  }
}
 

Example 69

From project dawn-isencia, under directory /com.isencia.passerelle.commons.ume/src/main/java/com/isencia/message/io/.

Source file: FileSenderChannel.java

  16 
vote

/** 
 * @param append
 * @throws ChannelException
 */
public void open(boolean append) throws ChannelException {
  if (logger.isTraceEnabled())   logger.trace("open() - entry");
  if (destFile == null)   throw new ChannelException("Destination file is not specified");
  try {
    if (encoding != null) {
      FileOutputStream fileOutputStream=new FileOutputStream(destFile);
      setWriter(new OutputStreamWriter(fileOutputStream,encoding));
    }
 else {
      setWriter(new FileWriter(destFile,append));
    }
  }
 catch (  UnsupportedEncodingException e) {
    throw new ChannelException("UnsupportedEncodingException " + encoding);
  }
catch (  IOException e) {
    logger.error("Error opening destination file " + destFile.getAbsolutePath(),e);
    throw new ChannelException("Error opening destination file " + destFile.getAbsolutePath() + " : "+ e.getMessage());
  }
  super.open();
  if (logger.isTraceEnabled())   logger.trace("open() - exit");
}
 

Example 70

From project dmix, under directory /JMPDComm/src/org/a0z/mpd/.

Source file: MPDConnection.java

  16 
vote

MPDConnection(InetAddress server,int port) throws MPDServerException {
  hostPort=port;
  hostAddress=server;
  commandQueue=new StringBuffer();
  try {
    mpdVersion=this.connect();
    if (mpdVersion[0] > 0 || mpdVersion[1] >= 10) {
      outputStream=new OutputStreamWriter(sock.getOutputStream(),"UTF-8");
      inputStream=new InputStreamReader(sock.getInputStream(),"UTF-8");
    }
 else {
      outputStream=new OutputStreamWriter(sock.getOutputStream());
      inputStream=new InputStreamReader(sock.getInputStream());
    }
  }
 catch (  IOException e) {
    throw new MPDServerException(e.getMessage(),e);
  }
}
 

Example 71

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/www/http/.

Source file: Webserver.java

  15 
vote

public PrintWriter getWriter() throws IOException {
synchronized (out) {
    if (pw == null) {
      if (rout != null)       throw new IllegalStateException("Already was returned as servlet output stream");
      String encoding=getCharacterEncoding();
      if (encoding != null)       pw=new PrintWriter(new OutputStreamWriter(out,encoding));
 else       pw=new PrintWriter(out);
    }
  }
  return pw;
}
 

Example 72

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/acewiki/core/.

Source file: OntologyExporter.java

  15 
vote

/** 
 * Writes the given string into the current output stream.
 * @param str The string to be written.
 * @throws IOException when an IO problem occurs.
 */
protected void write(String str) throws IOException {
  if (writer == null) {
    writer=new BufferedWriter(new OutputStreamWriter(outputStream));
  }
  writer.write(str);
}
 

Example 73

From project ACLS-protocol-library, under directory /aclslib/src/main/java/au/edu/uq/cmm/aclslib/message/.

Source file: AclsClient.java

  15 
vote

public Response serverSendReceive(Request r) throws AclsException {
  try {
    Socket aclsSocket=new Socket();
    try {
      aclsSocket.setSoTimeout(timeout);
      aclsSocket.connect(new InetSocketAddress(serverHost,serverPort),timeout);
      BufferedWriter w=new BufferedWriter(new OutputStreamWriter(aclsSocket.getOutputStream()));
      InputStream is=aclsSocket.getInputStream();
      LOG.debug("Sending ACLS server request " + r.getType().name() + "("+ r.unparse(true)+ ")");
      w.append(r.unparse(false) + "\r\n").flush();
      return new ResponseReaderImpl().readWithStatusLine(is);
    }
  finally {
      aclsSocket.close();
    }
  }
 catch (  SocketTimeoutException ex) {
    LOG.info("ACLS send / receive timed out");
    throw new AclsNoResponseException("Timeout while connecting or talking to ACLS server (" + serverHost + ":"+ serverPort+ ")",ex);
  }
catch (  IOException ex) {
    LOG.info("ACLS send / receive gave IO exception: " + ex.getMessage());
    throw new AclsCommsException("IO error while trying to talk to ACLS server (" + serverHost + ":"+ serverPort+ ")",ex);
  }
}
 

Example 74

From project agraph-java-client, under directory /src/com/franz/agraph/http/.

Source file: AGHttpRepoClient.java

  15 
vote

public void upload(final Reader contents,String baseURI,final RDFFormat dataFormat,boolean overwrite,Resource... contexts) throws RDFParseException, AGHttpException {
  final Charset charset=dataFormat.hasCharset() ? dataFormat.getCharset() : Charset.forName("UTF-8");
  RequestEntity entity=new RequestEntity(){
    public long getContentLength(){
      return -1;
    }
    public String getContentType(){
      String format=dataFormat.getDefaultMIMEType();
      if (format.contains("turtle")) {
        format="text/turtle";
      }
      return format + "; charset=" + charset.name();
    }
    public boolean isRepeatable(){
      return false;
    }
    public void writeRequest(    OutputStream out) throws IOException {
      OutputStreamWriter writer=new OutputStreamWriter(out,charset);
      IOUtil.transfer(contents,writer);
      writer.flush();
    }
  }
;
  upload(entity,baseURI,overwrite,null,null,null,contexts);
}
 

Example 75

From project aim3-tu-berlin, under directory /seminar/exercises/datamining/core/src/test/java/de/tuberlin/dima/aim/exercises/.

Source file: HadoopAndPactTestcase.java

  15 
vote

protected static void writeLines(File file,Iterable<String> lines) throws FileNotFoundException {
  PrintWriter writer=new PrintWriter(new OutputStreamWriter(new FileOutputStream(file),Charset.forName("UTF-8")));
  try {
    for (    String line : lines) {
      writer.println(line);
    }
  }
  finally {
    writer.close();
  }
}
 

Example 76

From project akela, under directory /src/main/java/com/mozilla/hadoop/.

Source file: Backup.java

  15 
vote

/** 
 * Get the input source files to be used as input for the backup mappers
 * @param inputFs
 * @param inputPath
 * @param outputFs
 * @return
 * @throws IOException
 */
public Path[] createInputSources(List<Path> paths,FileSystem outputFs) throws IOException {
  int suggestedMapRedTasks=conf.getInt("mapred.map.tasks",1);
  Path[] inputSources=new Path[suggestedMapRedTasks];
  for (int i=0; i < inputSources.length; i++) {
    inputSources[i]=new Path(NAME + "-inputsource" + i+ ".txt");
  }
  List<BufferedWriter> writers=new ArrayList<BufferedWriter>();
  int idx=0;
  try {
    for (    Path source : inputSources) {
      writers.add(new BufferedWriter(new OutputStreamWriter(outputFs.create(source))));
    }
    for (    Path p : paths) {
      writers.get(idx).write(p.toString());
      writers.get(idx).newLine();
      idx++;
      if (idx >= inputSources.length) {
        idx=0;
      }
    }
  }
  finally {
    for (    BufferedWriter writer : writers) {
      checkAndClose(writer);
    }
  }
  return inputSources;
}
 

Example 77

From project aksunai, under directory /src/org/androidnerds/app/aksunai/net/.

Source file: ConnectionThread.java

  15 
vote

public void run(){
  try {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"Connecting to... " + mServerDetail.mUrl + ":"+ mServerDetail.mPort);
    mSock=new Socket(mServerDetail.mUrl,mServerDetail.mPort);
  }
 catch (  UnknownHostException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"UnknownHostException caught, terminating connection process");
  }
catch (  IOException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"IOException caught on socket creation. (Server) " + mServer + ", (Exception) "+ e.toString());
  }
  try {
    mWriter=new BufferedWriter(new OutputStreamWriter(mSock.getOutputStream()));
    mReader=new BufferedReader(new InputStreamReader(mSock.getInputStream()));
  }
 catch (  IOException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"IOException caught grabbing input/output streams. (Server) " + mServer + ", (Exception) "+ e.toString());
  }
  mServer.init(mServerDetail.mPass,mServerDetail.mNick,mServerDetail.mUser,mServerDetail.mRealName);
  try {
    while (!shouldKill()) {
      String message=mReader.readLine();
      if (AppConstants.DEBUG)       Log.d(AppConstants.NET_TAG,"Received message: " + message);
      mServer.receiveMessage(message);
    }
  }
 catch (  IOException e) {
    if (AppConstants.DEBUG)     Log.d(AppConstants.NET_TAG,"IOException caught handling messages. (Server) " + mServer + ", (Exception) "+ e.toString());
  }
  return;
}
 

Example 78

From project anarchyape, under directory /src/main/java/ape/.

Source file: DenialOfServiceRunner.java

  15 
vote

public static void sendRawLine(String text,Socket sock){
  try {
    BufferedWriter out=new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
    out.write(text);
    out.flush();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 79

From project android-share-menu, under directory /src/com/eggie5/.

Source file: post_to_eggie5.java

  15 
vote

private void SendRequest(String data_string){
  try {
    String xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<photo><photo>" + data_string + "</photo><caption>via android - "+ new Date().toString()+ "</caption></photo>";
    String hostname="eggie5.com";
    String path="/photos";
    int port=80;
    InetAddress addr=InetAddress.getByName(hostname);
    Socket sock=new Socket(addr,port);
    BufferedWriter wr=new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),"UTF-8"));
    wr.write("POST " + path + " HTTP/1.1\r\n");
    wr.write("Host: eggie5.com\r\n");
    wr.write("Content-Length: " + xmldata.length() + "\r\n");
    wr.write("Content-Type: text/xml; charset=\"utf-8\"\r\n");
    wr.write("Accept: text/xml\r\n");
    wr.write("\r\n");
    wr.write(xmldata);
    wr.flush();
    BufferedReader rd=new BufferedReader(new InputStreamReader(sock.getInputStream()));
    String line;
    while ((line=rd.readLine()) != null) {
      Log.v(this.getClass().getName(),line);
    }
  }
 catch (  Exception e) {
    Log.e(this.getClass().getName(),"Upload failed",e);
  }
}
 

Example 80

From project android_external_guava, under directory /src/com/google/common/io/.

Source file: CharStreams.java

  15 
vote

/** 
 * Returns a factory that will supply instances of  {@link OutputStreamWriter}, using the given  {@link OutputStream} factory and character set.
 * @param out the factory that will be used to open output streams
 * @param charset the character set used to encode the output stream
 * @return the factory
 */
public static OutputSupplier<OutputStreamWriter> newWriterSupplier(final OutputSupplier<? extends OutputStream> out,final Charset charset){
  Preconditions.checkNotNull(out);
  Preconditions.checkNotNull(charset);
  return new OutputSupplier<OutputStreamWriter>(){
    public OutputStreamWriter getOutput() throws IOException {
      return new OutputStreamWriter(out.getOutput(),charset);
    }
  }
;
}
 

Example 81

From project archaius, under directory /archaius-core/src/test/java/com/netflix/config/.

Source file: DynamicFileConfigurationTest.java

  15 
vote

static File createConfigFile(String prefix) throws Exception {
  configFile=File.createTempFile(prefix,".properties");
  BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile),"UTF-8"));
  writer.write("dprops1=123456789");
  writer.newLine();
  writer.write("dprops2=79.98");
  writer.newLine();
  writer.close();
  System.err.println(configFile.getPath() + " created");
  return configFile;
}
 

Example 82

From project asterisk-java, under directory /src/main/java/org/asteriskjava/util/internal/.

Source file: SocketConnectionFacadeImpl.java

  15 
vote

private void initialize(Socket socket,Pattern pattern) throws IOException {
  this.socket=socket;
  InputStream inputStream=socket.getInputStream();
  OutputStream outputStream=socket.getOutputStream();
  BufferedReader reader=new BufferedReader(new InputStreamReader(inputStream));
  this.scanner=new Scanner(reader);
  this.scanner.useDelimiter(pattern);
  this.writer=new BufferedWriter(new OutputStreamWriter(outputStream));
}
 

Example 83

From project babel, under directory /src/babel/content/eqclasses/phrases/.

Source file: PhraseTable.java

  15 
vote

public void savePhraseTableChunk(Set<Phrase> srcPhrases,String phraseTableFile,PairFeat[] featsToWrite) throws IOException {
  if (phraseTableFile != null) {
    BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(phraseTableFile,true),m_encoding));
    List<Phrase> srcPhraseList=new ArrayList<Phrase>(srcPhrases);
    Collections.sort(srcPhraseList,new LexComparator(true));
    Map<Phrase,PairProps> trgMap;
    List<Phrase> trgPhraseList;
    for (    Phrase srcPhrase : srcPhraseList) {
      trgMap=m_phraseMap.get(srcPhrase);
      trgPhraseList=new ArrayList<Phrase>(trgMap.keySet());
      Collections.sort(trgPhraseList,new LexComparator(true));
      for (      Phrase trgPhrase : trgPhraseList) {
        writer.write(srcPhrase.getStem() + FIELD_DELIM + trgPhrase.getStem()+ FIELD_DELIM+ trgMap.get(trgPhrase).getPairFeatStr(featsToWrite)+ "\n");
      }
    }
    writer.close();
  }
}
 

Example 84

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/util/.

Source file: ViewServer.java

  15 
vote

private static boolean writeValue(Socket client,String value){
  boolean result;
  BufferedWriter out=null;
  try {
    OutputStream clientStream=client.getOutputStream();
    out=new BufferedWriter(new OutputStreamWriter(clientStream),8 * 1024);
    out.write(value);
    out.write("\n");
    out.flush();
    result=true;
  }
 catch (  Exception e) {
    result=false;
  }
 finally {
    if (out != null) {
      try {
        out.close();
      }
 catch (      IOException e) {
        result=false;
      }
    }
  }
  return result;
}
 

Example 85

From project blacktie, under directory /stompconnect-1.0/src/main/java/org/codehaus/stomp/jms/.

Source file: ProtocolConverter.java

  15 
vote

protected void onStompReceive(StompFrame command) throws IllegalStateException, SystemException, JMSException, NamingException, IOException {
  checkConnected();
  Map<String,Object> headers=command.getHeaders();
  String destinationName=(String)headers.remove(Stomp.Headers.Send.DESTINATION);
  String xid=(String)headers.get("messagexid");
  Message msg;
  StompSession session;
  if (xid != null) {
    log.trace("Transaction was propagated: " + xid);
    TransactionImple tx=controlToTx(xid);
    tm.resume(tx);
    log.trace("Resumed transaction: " + tx);
    session=getXASession(tx);
    msg=session.receiveFromJms(destinationName,headers);
    tm.suspend();
    log.trace("Suspended transaction: " + tx);
  }
 else {
    log.trace("WAS NULL XID");
    session=noneXaSession;
    msg=session.receiveFromJms(destinationName,headers);
    log.trace("Received from JMS");
  }
  StompFrame sf;
  if (msg == null) {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    PrintWriter stream=new PrintWriter(new OutputStreamWriter(baos,"UTF-8"));
    stream.print("No messages available");
    stream.close();
    Map<String,Object> eheaders=new HashMap<String,Object>();
    eheaders.put(Stomp.Headers.Error.MESSAGE,"timeout");
    sf=new StompFrame(Stomp.Responses.ERROR,eheaders,baos.toByteArray());
  }
 else {
    sf=session.convertMessage(msg);
  }
  if (headers.containsKey(Stomp.Headers.RECEIPT_REQUESTED))   sf.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID,headers.get(Stomp.Headers.RECEIPT_REQUESTED));
  sendToStomp(sf);
}
 

Example 86

From project book, under directory /src/main/java/com/tamingtext/classifier/bayes/.

Source file: ExtractTrainingData.java

  15 
vote

/** 
 * Obtain a writer for the training data assigned to the the specified category. <p> Maintains an internal hash of writers used for a category which must be closed by  {@link #closeWriters()}. <p>
 * @param outputDir
 * @param category
 * @return
 * @throws IOException
 */
protected static PrintWriter getWriterForCategory(File outputDir,String category) throws IOException {
  PrintWriter out=trainingWriters.get(category);
  if (out == null) {
    out=new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(outputDir,category))));
    trainingWriters.put(category,out);
  }
  return out;
}
 

Example 87

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: Logger.java

  15 
vote

/** 
 * Write the exception stacktrace to the error log file 
 * @param e The exception to log
 */
public static void logError(Exception e,String msg){
  DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  Date date=new Date();
  String now=dateFormat.format(date);
  StringWriter sw=new StringWriter();
  PrintWriter pw=new PrintWriter(sw);
  e.printStackTrace(pw);
  String error="An Exception Occured @ " + now + "\n"+ "In Phone "+ Build.MODEL+ " ("+ Build.VERSION.SDK_INT+ ") \n"+ msg+ "\n"+ sw.toString();
  try {
    Log.e("BC Logger",error);
    BufferedWriter out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(StorageUtils.getErrorLog()),"utf8"),8192);
    out.write(error);
    out.close();
  }
 catch (  Exception e1) {
  }
}
 

Example 88

From project Cafe, under directory /testservice/src/com/baidu/cafe/remote/.

Source file: Client.java

  15 
vote

/** 
 * @param command a command string which is run on server
 * @return the result string of the command
 */
public String runCmdOnServer(String command){
  Socket socket=null;
  String ret=null;
  PrintWriter out=null;
  BufferedReader in=null;
  Log.d("Client","run [" + command + "] at "+ mServerIP);
  try {
    socket=new Socket(InetAddress.getByName(mServerIP),7777);
    out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
    in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
    out.println(command);
    ret=in.readLine();
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    try {
      if (out != null) {
        out.close();
      }
      if (in != null) {
        in.close();
      }
      if (socket != null) {
        socket.close();
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  return ret;
}
 

Example 89

From project cascading, under directory /src/local/cascading/scheme/local/.

Source file: TextDelimited.java

  15 
vote

public PrintWriter createOutput(OutputStream outputStream){
  try {
    return new PrintWriter(new OutputStreamWriter(outputStream,"UTF-8"));
  }
 catch (  UnsupportedEncodingException exception) {
    throw new TapException(exception);
  }
}
 

Example 90

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/datacollection/agent/.

Source file: ChukwaAgent.java

  15 
vote

/** 
 * Called periodically to write checkpoints
 * @throws IOException
 */
private void writeCheckpoint() throws IOException {
  needNewCheckpoint=false;
synchronized (checkpointDir) {
    log.info("writing checkpoint " + checkpointNumber);
    FileOutputStream fos=new FileOutputStream(new File(checkpointDir,CHECKPOINT_BASE_NAME + checkpointNumber));
    PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(fos)));
    for (    Map.Entry<String,String> stat : getAdaptorList().entrySet()) {
      out.println("ADD " + stat.getKey() + " = "+ stat.getValue());
    }
    out.close();
    File lastCheckpoint=new File(checkpointDir,CHECKPOINT_BASE_NAME + (checkpointNumber - 1));
    log.debug("hopefully removing old checkpoint file " + lastCheckpoint.getAbsolutePath());
    lastCheckpoint.delete();
    checkpointNumber++;
  }
}
 

Example 91

From project cloudify, under directory /CLI/src/main/java/org/cloudifysource/shell/installer/.

Source file: LocalhostGridAgentBootstrapper.java

  15 
vote

private File createScript(final String text) throws CLIException {
  File tempFile;
  try {
    tempFile=File.createTempFile("run-gs-agent",isWindows() ? ".bat" : ".sh");
  }
 catch (  final IOException e) {
    throw new CLIException(e);
  }
  tempFile.deleteOnExit();
  BufferedWriter out=null;
  try {
    try {
      out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile)));
      if (!isWindows()) {
        out.write(LINUX_SCRIPT_PREFIX);
      }
      out.write(text);
    }
  finally {
      if (out != null) {
        out.close();
      }
    }
  }
 catch (  final IOException e) {
    throw new CLIException(e);
  }
  if (!isWindows()) {
    tempFile.setExecutable(true,true);
  }
  return tempFile;
}
 

Example 92

From project components-ness-httpserver_1, under directory /src/main/java/com/nesscomputing/httpserver/log/file/.

Source file: FileRequestLog.java

  15 
vote

@Override public void doStart(){
  if (requestLogFile.exists() && !requestLogFile.isFile()) {
    LOG.warn("Log file \"%s\" exists, but is not a file!",requestLogFile.getAbsolutePath());
    return;
  }
  final File logPath=requestLogFile.getParentFile();
  if (!logPath.mkdirs() && !logPath.exists()) {
    LOG.warn("Cannot create \"%s\" and path does not already exist!",logPath.getAbsolutePath());
  }
  LOG.info("Opening request log at \"%s\"",requestLogFile.getAbsolutePath());
  try {
    setWriter(new PrintWriter(new OutputStreamWriter(new FileOutputStream(requestLogFile,true),Charsets.UTF_8),true));
  }
 catch (  FileNotFoundException e) {
    LOG.error(e,"Could not open request log \"%s\"",requestLogFile.getAbsolutePath());
  }
}
 

Example 93

From project cornerstone, under directory /frameworks/base/services/java/com/android/server/wm/.

Source file: WindowManagerService.java

  15 
vote

/** 
 * Lists all availble windows in the system. The listing is written in the specified Socket's output stream with the following syntax: windowHashCodeInHexadecimal windowName Each line of the ouput represents a different window.
 * @param client The remote client to send the listing to.
 * @return False if an error occured, true otherwise.
 */
boolean viewServerListWindows(Socket client){
  if (isSystemSecure()) {
    return false;
  }
  boolean result=true;
  WindowState[] windows;
synchronized (mWindowMap) {
    windows=mWindows.toArray(new WindowState[mWindows.size()]);
  }
  BufferedWriter out=null;
  try {
    OutputStream clientStream=client.getOutputStream();
    out=new BufferedWriter(new OutputStreamWriter(clientStream),8 * 1024);
    final int count=windows.length;
    for (int i=0; i < count; i++) {
      final WindowState w=windows[i];
      out.write(Integer.toHexString(System.identityHashCode(w)));
      out.write(' ');
      out.append(w.mAttrs.getTitle());
      out.write('\n');
    }
    out.write("DONE.\n");
    out.flush();
  }
 catch (  Exception e) {
    result=false;
  }
 finally {
    if (out != null) {
      try {
        out.close();
      }
 catch (      IOException e) {
        result=false;
      }
    }
  }
  return result;
}
 

Example 94

From project data-bus, under directory /databus-worker/src/test/java/com/inmobi/databus/distcp/.

Source file: TestDistCPBaseService.java

  15 
vote

private void createInvalidData() throws IOException {
  localFs.mkdirs(testRoot);
  Path dataRoot=new Path(testRoot,service.getInputPath());
  localFs.mkdirs(dataRoot);
  Path p=new Path(dataRoot,"file1-empty");
  localFs.create(p);
  p=new Path(dataRoot,"file-with-junk-data");
  FSDataOutputStream out=localFs.create(p);
  BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(out));
  writer.write("junkfile-1\n");
  writer.write("junkfile-2\n");
  writer.close();
}
 

Example 95

From project datavalve, under directory /datavalve-dataset/src/test/java/org/fluttercode/datavalve/provider/file/.

Source file: CommaDelimitedDatasetTest.java

  15 
vote

private void generateFile(){
  baseDir=System.getProperty("java.io.tmpdir") + "/CsvDsTest/";
  fileName=baseDir + "csvFile.csv";
  File base=new File(baseDir);
  base.mkdir();
  FileOutputStream fs=null;
  try {
    fs=new FileOutputStream(new File(fileName));
    BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(fs));
    for (int i=0; i < 100; i++) {
      writer.write(Integer.toString(i + 1));
      writer.write(",");
      writer.write(getDataFactory().getFirstName());
      writer.write(",");
      writer.write(getDataFactory().getLastName());
      writer.write(",");
      writer.write(getDataFactory().getNumberText(10));
      writer.newLine();
    }
    writer.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 96

From project dawn-ui, under directory /org.dawb.workbench.plotting/src/org/dawb/workbench/plotting/tools/fitting/.

Source file: FittingTool.java

  15 
vote

/** 
 * Will export to file and overwrite. Will append ".csv" if it is not already there.
 * @param path
 */
String exportFittedPeaks(final String path) throws Exception {
  File file=new File(path);
  if (!file.getName().toLowerCase().endsWith(".dat"))   file=new File(path + ".dat");
  if (file.exists())   file.delete();
  final BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
  try {
    writer.write(FittedPeak.getCVSTitle());
    writer.newLine();
    for (    FittedPeak peak : this.fittedPeaks.getPeakList()) {
      writer.write(peak.getTabString());
      writer.newLine();
    }
  }
  finally {
    writer.close();
  }
  return file.getAbsolutePath();
}
 

Example 97

From project dcm4che, under directory /dcm4che-tool/dcm4che-tool-hl7rcv/src/main/java/org/dcm4che/tool/hl7rcv/.

Source file: HL7Rcv.java

  15 
vote

private byte[] xslt(HL7Segment msh,byte[] msg,int off,int len) throws Exception {
  String charsetName=HL7Charset.toCharsetName(msh.getField(17,charset));
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  TransformerHandler th=factory.newTransformerHandler(tpls);
  Transformer t=th.getTransformer();
  t.setParameter("MessageControlID",HL7Segment.nextMessageControlID());
  t.setParameter("DateTimeOfMessage",HL7Segment.timeStamp(new Date()));
  if (xsltParams != null)   for (int i=1; i < xsltParams.length; i++, i++)   t.setParameter(xsltParams[i - 1],xsltParams[i]);
  th.setResult(new SAXResult(new HL7ContentHandler(new OutputStreamWriter(out,charsetName))));
  new HL7Parser(th).parse(new InputStreamReader(new ByteArrayInputStream(msg,off,len),charsetName));
  return out.toByteArray();
}
 

Example 98

From project dozer, under directory /eclipse-plugin/net.sf.dozer.eclipse.plugin/src/org/dozer/eclipse/plugin/wizards/.

Source file: NewMappingConfigFilePage.java

  15 
vote

protected InputStream createXMLDocument() throws Exception {
  ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
  String charSet=getUserPreferredCharset();
  PrintWriter writer=new PrintWriter(new OutputStreamWriter(outputStream,charSet));
  writer.println("<?xml version=\"1.0\" encoding=\"" + charSet + "\"?>");
  if (dozerVersionCombo.getSelectionIndex() == 0) {
    writer.println("<!DOCTYPE mappings PUBLIC \"-//DOZER//DTD MAPPINGS//EN\" \"http://dozer.sourceforge.net/dtd/dozerbeanmapping.dtd\">");
    writer.println("<mappings>");
  }
 else   if (dozerVersionCombo.getSelectionIndex() == 1) {
    writer.println("<mappings xmlns=\"http://dozer.sourceforge.net\"");
    writer.println("      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    writer.println("      xsi:schemaLocation=\"http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd\">");
  }
  writer.println("</mappings>");
  writer.flush();
  outputStream.close();
  ByteArrayInputStream inputStream=new ByteArrayInputStream(outputStream.toByteArray());
  return inputStream;
}