Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.tools;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.LineNumberReader;
- import java.io.OutputStreamWriter;
- import java.io.Writer;
- import java.util.ArrayList;
- import java.util.List;
- public class FileWriting {
- public static String content;
- public static String itemName;
- private static final String newLine = System.getProperty("line.separator");
- public static List<Long> priceListArray = new ArrayList<Long>();
- public static long lowerPercentile;
- public static long upperPercentile;
- public void writing() {
- try {
- //Change the file location to whatever suits your OS
- File fileLocation = new File("C:/Users/userr/Desktop/TriBot/miningTimeTaken.txt");
- FileOutputStream fos = new FileOutputStream(fileLocation, true);
- OutputStreamWriter osw = new OutputStreamWriter(fos);
- Writer w = new BufferedWriter(osw);
- if (!fileLocation.exists()) {
- fileLocation.createNewFile();
- System.out.println(itemName + " has not been analised. " + itemName + ".txt Sucessfully created...");
- }
- w.write(newLine + content);
- System.out.println("Data written to: " + itemName +".txt");
- w.close();
- } catch (IOException e) {
- System.err.println("There was an error writing to the file " + itemName + ".txt");
- }
- }
- public static void WriteFile(String toWrite) {
- content = toWrite;
- FileWriting write = new FileWriting();
- write.writing();
- }
- public static int LineNumber() throws IOException {
- LineNumberReader lnr = new LineNumberReader(new FileReader(new File("C:/Users/Josh/Desktop/Parabot/JMerch/PriceData/" + itemName + ".txt")));
- lnr.skip(Long.MAX_VALUE);
- lnr.close();
- return lnr.getLineNumber() + 1; //Add 1 because line index starts at 0
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement