自己总结的Java实现文件的读写操作
做个笔记,针对java 的file的操作1.根据文件名及字符串,写文件
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gifpublic static boolean writeJiang(String content,String path,String name)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif try...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif File file = new File(path);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif System.out.println("文件的路径是:" + file+"/"+name);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif BufferedWriter fileout = new BufferedWriter(new FileWriter(file+"/"+name,true));
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif fileout.write(content);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif fileout.write(" ");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif fileout.flush();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif fileout.close();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif catch(Exception e)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif e.printStackTrace();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif System.out.println("写文件完毕");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return true;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif }
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
页:
[1]