List of usage examples for java.io BufferedWriter BufferedWriter
public BufferedWriter(Writer out)
From source file:Main.java
public static void appendLog(String text) { Log.d("LOGFILE", text); SimpleDateFormat sTime = new SimpleDateFormat("dd/MMM/yyyy - hh:mm:ss"); String timeFormat = sTime.format(new Date()); File sdCard = Environment.getExternalStorageDirectory(); File dir = new File(sdCard.getAbsolutePath() + "/Cura/Logs/"); dir.mkdirs();//from w w w . j a v a2 s . c om File logFile = new File(dir, "Cura_Logs_DEBUG.txt"); if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } try { BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true)); if (text.compareTo("wipe") == 0) logFile.delete(); else { buf.append("[" + timeFormat + "] - "); buf.append(text); buf.newLine(); buf.close(); } } catch (IOException e) { e.printStackTrace(); } }
From source file:at.ac.tuwien.dsg.cloudlyra.utils.IOUtils.java
public static void writeData(String data, String fileName) { String tomcatTempFolder = System.getProperty("java.io.tmpdir"); //String tomcatTempFolder="/Volumes/DATA/BigData"; fileName = tomcatTempFolder + "/" + fileName; FileWriter fstream;//from w w w .j a va 2s.co m try { fstream = new FileWriter(fileName, false); BufferedWriter out = new BufferedWriter(fstream); out.write(data); out.close(); } catch (IOException ex) { } }
From source file:Main.java
public static boolean writeFile(String filename, String content) { boolean isSuccess = false; BufferedWriter bufferedWriter = null; try {// www . j av a 2s .c om bufferedWriter = new BufferedWriter(new FileWriter(filename, false)); bufferedWriter.write(content); isSuccess = true; } catch (IOException e) { e.printStackTrace(); } finally { closeIO(bufferedWriter); } return isSuccess; }
From source file:Main.java
public static boolean writeFile(String filename, String content, boolean append) { boolean isSuccess = false; BufferedWriter bufferedWriter = null; try {/*from w ww . j av a 2 s . c o m*/ bufferedWriter = new BufferedWriter(new FileWriter(filename, append)); bufferedWriter.write(content); isSuccess = true; } catch (IOException e) { e.printStackTrace(); } finally { closeIO(bufferedWriter); } return isSuccess; }
From source file:Main.java
public static BufferedWriter createBuffWriter(File file) throws FileNotFoundException, UnsupportedEncodingException { return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); }
From source file:WriteFile.java
private static PrintWriter openWriter(String name) { try {/*from w w w . ja v a 2s .co m*/ File file = new File(name); PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)), true); return out; } catch (IOException e) { System.out.println("I/O Error"); System.exit(0); } return null; }
From source file:JGraphLoader.GraphSaver.java
public static void saveG(String filename, Graph g) { final AbstractLayout layout = new StaticLayout(g); GraphMLWriter<node, edge> graphWriter = new GraphMLWriter<node, edge>(); try {/*from w w w .ja v a 2 s .c o m*/ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename))); graphWriter.addEdgeData("id", null, "0", new Transformer<edge, String>() { @Override public String transform(edge i) { return i.getValue(); } }); /* graphWriter.addVertexData("y", null, "0", new Transformer<node, String>() { public String transform(node v) { return Double.toString(layout.getY(v)); } } );*/ graphWriter.save(g, out); } catch (IOException ex) { Logger.getLogger(GraphSaver.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.lunix.cheata.utils.file.FileManager.java
public static void createFile(String fileName) { try {// w ww. ja v a2 s .co m BufferedWriter writer = new BufferedWriter(new FileWriter(new File(dir.getAbsolutePath(), fileName))); writer.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void WriteAllText(String path, String text) throws IOException { BufferedWriter writer = null; try {//from w ww . j a v a 2 s . c o m FileWriter output = new FileWriter(path); writer = new BufferedWriter(output); writer.write(text); } finally { if (writer != null) writer.close(); } }
From source file:Main.java
public static void handleClientRequest(Socket socket) { try {/*from w ww .j ava2 s . co m*/ BufferedReader socketReader = null; BufferedWriter socketWriter = null; socketReader = new BufferedReader(new InputStreamReader(socket.getInputStream())); socketWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); String inMsg = null; while ((inMsg = socketReader.readLine()) != null) { System.out.println("Received from client: " + inMsg); String outMsg = inMsg; socketWriter.write(outMsg); socketWriter.write("\n"); socketWriter.flush(); } socket.close(); } catch (Exception e) { e.printStackTrace(); } }